使用 AutoIT 实现多个网页的自动化
Automation of multiple web pages using AutoIT
#include <string.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <WinAPIFiles.au3>
#include <Misc.au3>
#include <AutoItConstants.au3>
#include <Date.au3>
#include <IE.au3>
#include <Inet.au3>
Local $oIE = _IECreate("www.google.com",1,1,1,1)
Sleep(2000)
_IELoadWait($oIE)
Sleep(2000)
$o_form = _IEFormGetObjByName($oIE, "f")
$element = _IEFormElementGetObjByName($o_form,"q")
_IEFormElementSetValue($element,"INDIA")
Sleep(2000)
;~ Send("{ENTER}")
;~ $btn = _IEFormElementGetObjByName($o_form,"gsr")
;~ _IEAction($element,"click")
_IEFormSubmit($o_form)
Sleep(2000)
_IELinkClickByText($oIE, "India - Wikipedia")
Sleep(3000)
;~ $Set = _IEFormGetObjByName($o_form,"search")
;~ _IEFormElementSetValue($Set,"MAHARASHTRA")
$OIE1 = _IEPropertyGet($oIE, 'locationurl')
_IELoadWait($OIE1)
Sleep(2000)
MsgBox($MB_SYSTEMMODAL,"","New Page",3)
;~ $form = _IEFormGetObjByName($OIE1,"searchform")
;~ $select = _IEFormElementGetObjByName($form,"searchInput")
;~ Sleep(2000)
;~ _IEFormElementSetValue($select,"MAHARASHTRA")
_IELinkClickByText($OIE1,"second-most populous")
我正在使用 AutoIt 进行 Web 自动化。但是只有两三个页面可以使用 AutoIt 实现自动化。对于更多页面,代码无效。
有人可以帮我吗?如何自动化多个网页?
您可以使用 _IEAttach()
通过标题、url、句柄或其他参数附加 IE 的新实例。参见 here。
Local $oIE = _IECreate("www.google.com",1,1,1,1)
_IELoadWait($oIE)
Sleep(2000)
$o_form = _IEFormGetObjByName($oIE, "f")
$element = _IEFormElementGetObjByName($o_form,"q")
_IEFormElementSetValue($element,"INDIA")
Sleep(2000)
_IEFormSubmit($o_form)
Sleep(2000)
_IELinkClickByText($oIE, "India - Wikipedia")
Sleep(3000)
$OIE1 = _IEAttach("India - Wikipedia")
_IELoadWait($OIE1)
Sleep(2000)
MsgBox($MB_SYSTEMMODAL,"","New Page",3)
_IELinkClickByText($OIE1,"second-most populous")
#include <string.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <WinAPIFiles.au3>
#include <Misc.au3>
#include <AutoItConstants.au3>
#include <Date.au3>
#include <IE.au3>
#include <Inet.au3>
Local $oIE = _IECreate("www.google.com",1,1,1,1)
Sleep(2000)
_IELoadWait($oIE)
Sleep(2000)
$o_form = _IEFormGetObjByName($oIE, "f")
$element = _IEFormElementGetObjByName($o_form,"q")
_IEFormElementSetValue($element,"INDIA")
Sleep(2000)
;~ Send("{ENTER}")
;~ $btn = _IEFormElementGetObjByName($o_form,"gsr")
;~ _IEAction($element,"click")
_IEFormSubmit($o_form)
Sleep(2000)
_IELinkClickByText($oIE, "India - Wikipedia")
Sleep(3000)
;~ $Set = _IEFormGetObjByName($o_form,"search")
;~ _IEFormElementSetValue($Set,"MAHARASHTRA")
$OIE1 = _IEPropertyGet($oIE, 'locationurl')
_IELoadWait($OIE1)
Sleep(2000)
MsgBox($MB_SYSTEMMODAL,"","New Page",3)
;~ $form = _IEFormGetObjByName($OIE1,"searchform")
;~ $select = _IEFormElementGetObjByName($form,"searchInput")
;~ Sleep(2000)
;~ _IEFormElementSetValue($select,"MAHARASHTRA")
_IELinkClickByText($OIE1,"second-most populous")
我正在使用 AutoIt 进行 Web 自动化。但是只有两三个页面可以使用 AutoIt 实现自动化。对于更多页面,代码无效。
有人可以帮我吗?如何自动化多个网页?
您可以使用 _IEAttach()
通过标题、url、句柄或其他参数附加 IE 的新实例。参见 here。
Local $oIE = _IECreate("www.google.com",1,1,1,1)
_IELoadWait($oIE)
Sleep(2000)
$o_form = _IEFormGetObjByName($oIE, "f")
$element = _IEFormElementGetObjByName($o_form,"q")
_IEFormElementSetValue($element,"INDIA")
Sleep(2000)
_IEFormSubmit($o_form)
Sleep(2000)
_IELinkClickByText($oIE, "India - Wikipedia")
Sleep(3000)
$OIE1 = _IEAttach("India - Wikipedia")
_IELoadWait($OIE1)
Sleep(2000)
MsgBox($MB_SYSTEMMODAL,"","New Page",3)
_IELinkClickByText($OIE1,"second-most populous")