HotKeySet("{ESC}","quit")
;这个是定义全局的目录变量, 可以自己改成你自己的目录
Global $Path="d:\aa"
;打开DLL文件
$dll = DllOpen("user32.dll")
;设置DLL回调函数
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
;启动定时器
$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 100, "ptr", DllCallbackGetPtr($Timer))
;你要写的代码只能写在这据注释之下,要不然定时器不会运行。
ShellExecute($Path)
While 1
Sleep(100)
WEnd
Func quit() ;退出, 关闭定时器, 释放回调函数指针,关闭DLL
DllCall($dll, "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)
DllClose($dll)
Exit
EndFunc
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime) ;检测窗体。
If WinExists($Path) Then ControlClick($Path,"","Button1","left",1)
EndFunc
我的代码可完美实现你要的效果。 |