内嵌IE点击弹出新窗口后如何保持原有会话?
写了一个脚本,内嵌IE,点击某“查看/打印”的功能,会弹出新的IE窗口,但是此时会要求重新登录。如果用IE的话是没有问题的,即是弹出新窗口不用登录系统。 本帖最后由 gczxhzb 于 2013-8-7 11:07 编辑
保持弹出窗口仍然是内嵌即可,用标签页,写个简单例子给你,只是提供了思路。#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <IE.au3>
Global $TABS,$nTab=1
$Form1 = GUICreate(" 例子", @DesktopWidth, @DesktopHeight - 50);创建窗体
$hTab = GUICtrlCreateTab(5, 40, @DesktopWidth - 10, @DesktopHeight - 120);创建标签
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT);控制标签大小
GUICtrlCreateTabItem("")
$Stu = GUICtrlCreateButton("登陆", 5, 5, 75, 25, $WS_GROUP)
$Onhook = GUICtrlCreateButton("弹出", 85, 5, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Stu
_bg()
Case $Onhook
_tc()
EndSwitch
sleep(100)
WEnd
func _bg()
If Not IsArray($TABS) Then
Dim $TABS
Else
ReDim $TABS
EndIf
$TABS = GUICtrlCreateTabItem("请先登陆")
_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 5, 58, @DesktopWidth - 10, @DesktopHeight - 138)
_IENavigate($oIE, "http://www.baidu.com");百度主页,加载后先登陆
GUICtrlCreateTabItem("")
endfunc
func _tc();在主页上登陆后再进入此处
$url="http://pan.baidu.com/disk/home";百度网盘,这个是弹出另开的(你说的“查询/打印”按钮指向的地址)
ReDim $TABS
$TABS = GUICtrlCreateTabItem("弹出"&$nTab)
_IEErrorHandlerRegister()
$aIE = _IECreateEmbedded()
GUICtrlCreateObj($aIE, 5, 58, @DesktopWidth - 10, @DesktopHeight - 138)
_IENavigate($aIE, $url)
$nTab += 1
GUICtrlCreateTabItem("")
endfunc
页:
[1]