|
发表于 2010-7-9 09:13:47
|
显示全部楼层
刚在网上查了些资料。又做了测试。
把lanfengc后面的代码修改一下:
循环里这个位置:
------------------------------------------------------
;这里你可以自己检测鼠标点击的是什么控件,按你的要求做相应的响应。
$cursor = _WinAPI_GetCursorInfo()
If $cursor[2]=65581 And _IsPressed("1", $dll) And WinActive($GUIMain) Then
;我测试用延迟不管用。必须用MSGBOX断下程序执行。然后才能正常。
MsgBox(0,"提示", "End Key Pressed",10)
If $Text2<>"" Then $oIE.Navigate( $Text2 )
EndIf
-----------------------------------------------------------------
再把代码开始的
Global Const $HandCursorID=0X0001001F
这一行删掉。
65553是普通光标 65581是手型光标。
当条件是手型光标且被点击时触发oIE.Navigate
lanfengc的代码全部如下:#include "GUIConstantsEx.au3"
#include <IE.au3>
#include <Misc.au3>
#include <WinAPI.au3>
Dim $Text,$Text2="",$URL = "http://site.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
;这里你可以自己检测鼠标点击的是什么控件,按你的要求做相应的响应。
$cursor = _WinAPI_GetCursorInfo()
If $cursor[2]=65581 And _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
|
评分
-
查看全部评分
|