Used to remove an Idle timer from a mouse move. Detect mouse and keyboard movement.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
#include <Timers.au3> $toggle = true Global $iLimit = 180 ; idle limit in seconds HotKeySet("{ESC}", "_Quit") AdlibRegister("_CheckIdleTime", 500) While 1 Sleep(20) WEnd Func _CheckIdleTime() If _Timer_GetIdleTime() > $iLimit * 1000 Then if ($toggle = true) Then MouseMove(MouseGetPos(0),MouseGetPos(1)+100) $toggle = false Else MouseMove(MouseGetPos(0),MouseGetPos(1)-100) $toggle = true EndIf EndIf EndFunc ;==>_CheckIdleTime Func _Quit() Exit EndFunc ;==>_Quit Exit $begin = TimerInit() $keys = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "") $dll = DllOpen('user32.dll') While 1 $moved = "no" $pos1 = MouseGetPos() Sleep(50) $pos2 = MouseGetPos() If $pos1[0] <> $pos2[0] Then $moved = "yes" If $pos1[1] <> $pos2[1] Then $moved = "yes" If $moved = "yes" Then $begin = TimerInit() EndIf ;5minutes = 300000 If TimerDiff($begin) > 3000 And $moved = "no" Then if ($toggle = true) Then MouseMove(MouseGetPos(0),MouseGetPos(1)+100) $toggle = false Else MouseMove(MouseGetPos(0),MouseGetPos(1)-100) $toggle = true EndIf ;WinSetState("C:\Doc", "", @SW_MINIMIZE) $begin = TimerInit() EndIf WEnd While 1 Sleep(250) If _IsPressed("23", $dll) Then MsgBox(0, "_IsPressed", "End Key Pressed") ExitLoop EndIf For $x = 1 To $keys[0] If _IsPressed(Hex(Asc($keys[$x]),2)) Then MsgBox(0, "key pressed", $keys[$x]) EndIf Next WEnd DllClose($dll) Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') ; $hexKey must be the value of one of the keys. ; _Is_Pressed will return 0 if the key is not pressed, 1 if it is. Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed Exit #include <WindowsConstants.au3> GUIRegisterMsg($WM_KEYDOWN, "IsPressed") ;GUIRegisterMsg($WM_SYSKEYDOWN, "IsPressed") Func IsPressed() $begin = TimerInit() MsgBox(0,"test","test",0) EndFunc |