autoit没有随机点击IE嵌入式版本

时间:2014-06-18 10:16:10

标签: internet-explorer autoit

我想要的是创建IE嵌入式版本并打开mysite.com并打开随机链接。

#include <IE.au3>
#include <GUIConstantsEx.au3>
$width = 800
$height = 600
$hMain=GUICreate("TEST",800,600,@DesktopWidth/2-$width/2,@DesktopHeight/2-$height/2)
$oIE = ObjCreate("Shell.Explorer.2")
$GUIActiveX = GUICtrlCreateObj ($oIE, 0, 0, $width+3, $height+2)
$oIE.navigate("www.mysite.com")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
$oIE._IELinkClickByIndex($oIE, Random(0, $iNumLinks -1))
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    WinSetTitle($hMain,"",_IEPropertyGet($oIE, "title"))
WEnd

这是 Milos 给我的代码,可以从网站获取所有链接并打开随机链接。当我在IE上工作时它工作正常,但在IE嵌入式版本中,它没有...... :(

Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
_IELinkClickByIndex($oIE, Random(0, $iNumLinks))

所以需要帮助才能使它在IE嵌入式版本上运行

1 个答案:

答案 0 :(得分:0)

在那里,它是固定的。

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister()

$width = 800
$height = 600

Local $oIE = _IECreateEmbedded()
$hMain=GUICreate("TEST",800,600,@DesktopWidth/2-$width/2,@DesktopHeight/2-$height/2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 0, 0, $width+3, $height+20)

GUISetState() ;Show GUI

_IENavigate($oIE, "www.mysite.com")

Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
_IELinkClickByIndex($oIE, Random(0, $iNumLinks -1))
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    WinSetTitle($hMain,"",_IEPropertyGet($oIE, "title"))
WEnd