jing Posted October 10, 2006 Share Posted October 10, 2006 I want to write a program that can react to the user's action including mouse click, mouse release, and key pressed. The following code is an example that can achieve my goal(Thanks, Larry). However, it reacts to mouse movement as well, which I don't want. Anybody can give me a hint how to achieve my goal perfectly?HotKeySet("{Esc}", "_Terminate")Dim $last_active = 0Dim $timer = TimerInit()While (1) $not_idle = _CheckIdle($last_active) If $not_idle <> 0 Then $timer = TimerInit() ToolTip(Int(TimerDiff($timer)/1000)) Sleep(200)WEndFunc _CheckIdle(ByRef $last_active, $start = 0) $struct = DllStructCreate("uint;dword"); DllStructSetData($struct, 1, DllStructGetSize($struct)); If $start Then DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct)) $last_active = DllStructGetData($struct, 2) Return $last_active Else DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct)) If $last_active <> DllStructGetData($struct, 2) Then Local $save = $last_active $last_active = DllStructGetData($struct, 2) Return $last_active - $save EndIf EndIfEndFunc ;==>_CheckIdleFunc _Terminate() ExitEndFunc ;==>_Terminate Link to comment Share on other sites More sharing options...
jing Posted October 11, 2006 Author Share Posted October 11, 2006 nobody can give me a word? Link to comment Share on other sites More sharing options...
Zedna Posted October 11, 2006 Share Posted October 11, 2006 (edited) GetLastInputInfo API function can't do that, so maybe some workaround For example try to test Mouse position by MouseGetPos() - if changes mouse position then ignore GetLastInputInfo. Edited October 11, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
jing Posted October 16, 2006 Author Share Posted October 16, 2006 that is not a straight forward way to do that. There must be some function or functions can directly detect the key press or mouse click. Anybody knows that? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now