使用 _IECreate() 创建新会话 [英] Create new session using _IECreate()

查看:62
本文介绍了使用 _IECreate() 创建新会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 AutoIt 脚本.两者都包含 Global $oIE = _IECreate($myUrl, 1).他们为同一个 URL 创建了两个 IE 窗口.

I have two AutoIt scripts. Both contain Global $oIE = _IECreate($myUrl, 1). They create two IE windows for the same URL.

在 IE 中,当从文件"菜单中选择新建会话"时,每个窗口都有自己的会话.但是同时使用两个不同的脚本文件,两个窗口都登录到同一个帐户.如何使用新会话打开每个 IE 窗口?

In IE, when selecting "new session" from "file" menu, each window gets its own session. But using two different script files at the same time, both windows login to the same account. How can I open every IE window with a new session?

推荐答案

会话与每个唯一的 iexplore.exe 进程相关.每个所需会话启动 iexplore.exe 的新实例(未经测试,无错误检查):

Sessions relate to each unique iexplore.exe process. Start new instance of iexplore.exe per required session (untested, no error checking) :

#include <IE.au3>

Global Const $g_sUrl = 'https://stackoverflow.com/'
Global       $g_aIE[2]

For $i1 = 0 To UBound($g_aIE, 1) -1    
    _IECreateSession($g_aIE[$i1], $g_sUrl)    
Next

Func _IECreateSession(ByRef $oIE, Const $sUrl)
    Local Const $iPID = ShellExecute('iexplore.exe', '-nosessionmerging about:blank')
    Local       $aWnd

    WinWait('Blank Page')       
    $aWnd = _WinAPI_EnumProcessWindows($iPID, True)
    $oIE  = _IEAttach($aWnd[1][1], 'hwnd')    
    _IELoadWait($oIE)
    _IENavigate($oIE, $sUrl)

    Return $iPID    
EndFunc

这篇关于使用 _IECreate() 创建新会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆