|
发表于 2010-12-15 11:49:32
|
显示全部楼层
#include "GUIConstantsEx.au3"
#include <IE.au3>
#include <Misc.au3>
Dim $Text,$Text2="",$URL = "http://www.baidu.com/"
$dll = DllOpen("user32.dll")
$GUIMain=GUICreate ( "Event Test", 800,600 )
$GUIEdit=GUICtrlCreateEdit ( "Test Log:" & @CRLF, 10, 20, 780, 270)
$StateLab = GUICtrlCreateLabel("Label1", 8, 288, 780, 17)
GUISetState ()
$oIE = _IECreateEmbedded ()
GUICtrlCreateObj($oIE,8, 320, 780, 320)
$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")
if @error then exit Msgbox(0,"错误!","不可使用COM接口 'DWebBrowserEvents'. 错误代码: " & hex(@error,8))
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10, "ptr", DllCallbackGetPtr($Timer))
$oIE.Navigate( $URL )
sleep(1000)
GUISwitch ( $GUIMain )
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
$EventObject.Stop ; 不再接收事件
$EventObject=0 ; 关闭Event Object
$oIE=0 ; 清除内存
GUIDelete ()
DllCall($dll, "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)
DllClose($dll)
Exit
EndIf
;这里你可以自己检测鼠标点击的是什么控件,按你的要求做相应的响应。
If _IsPressed("1", $dll) And WinActive($GUIMain) Then
;我测试用延迟不管用。必须用MSGBOX断下程序执行。然后才能正常。
MsgBox(0,"提示", "End Key Pressed",10)
If $Text2<>"" Then $oIE.Navigate( $Text2 )
EndIf
Wend
;其实例子中那么多函数,真正要用到的只有这个。
Func IEEvent_StatusTextChange($Text)
If $Text<>'' Then GUICtrlSetData ( $GUIEdit, "IE Status text changed to: " & $Text & @CRLF , "append" )
If $Text<>'' And StringLeft($Text,4)="http" Then $Text2=$Text
GUICtrlSetData($StateLab,$Text)
EndFunc
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If WinExists("提示") Then
WinMove("提示","",@DesktopWidth,@DesktopHeight,0,0,1)
Send("{Enter}")
EndIf
EndFunc
这是曾经论坛中的一个例子。不知道能帮到LZ不。。。 |
|