Skip to content

Instantly share code, notes, and snippets.

@brimston3
Last active December 7, 2024 17:54
Show Gist options
  • Save brimston3/1292d0961a411ee641dd to your computer and use it in GitHub Desktop.
Save brimston3/1292d0961a411ee641dd to your computer and use it in GitHub Desktop.
Anti-idle autoit3 script. Use the windows idle timer to figure out the last input event. Useful when VMs don't have focus.
#cs
Copyright (C) March 30, 2015, Andrew Domaszek
(MIT License)
#ce
;#include <MsgBoxConstants.au3>
TraySetIcon ("Shell32.dll", 28)
TraySetToolTip ("Miggle" & @CRLF & "De-idle.")
Func _GetTicksFromGLII()
Local $LastInputInfo = DllStructCreate("uint;dword")
DllStructSetData($LastInputInfo, 1, DllStructGetSize($LastInputInfo))
DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($LastInputInfo))
Return DllStructGetData($LastInputInfo, 2)
EndFunc ;==>_GetTicksFromGLII
Func _GetTicksFromGTC()
Local $aResult = DllCall("Kernel32.dll", "dword", "GetTickCount")
Return $aResult[0]
EndFunc ;==>_GetTicksFromGTC
While 1
Local $iClock, $tiTicks, $mbrc
$x = MouseGetPos (0)
$iClock = _GetTicksFromGTC()
sleep (10000) ; 120000 msec == 2 min
$Current = MouseGetPos (0)
$tiTicks = _GetTicksFromGLII();
If $Current = $x And $tiTicks <= $iClock Then
;$mbrc = MsgBox($MB_OKCANCEL, "LastMsg", StringFormat("Ticks %d/%d", $iClock, $tiTicks))
;If $mbrc = $IDCANCEL Then
; Exit 0
;EndIf
$y = MouseGetPos (1)
MouseMove ($Current + Random(-20,20,1), $y + Random(-20,20,1), 5)
MouseMove ($x, $y, 5)
EndIf
WEnd
@brimston3
Copy link
Author

Conveniently not a keylogger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment