Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
KEYWORDS: GetLastInputInfo User Input Idle Mouse Key Keystroke Last Activity Time getTickCount
#DefineFunction Idle_Tick() ; Get the system uptime systemUptime = GetTickCount() ; The tick at which the last input was recorded LastInputTicks = 0 ; The number of ticks that passed since last input IdleTicks = 0 ; Set the struct LastInputInfo = BinaryAlloc(8) BinaryPoke4(LastInputInfo,0,8);cbSize BinaryPoke4(LastInputInfo,4,0);dwTime ; If we have a value from the function ret = DllCall(DirWindows(1):'user32.dll',long:'GetLastInputInfo',lpbinary:LastInputInfo) If ret ; Get the number of ticks at the point when the last activity was seen LastInputTicks = BinaryPeek4(LastInputInfo,4) ;dwTime ; Number of idle ticks = system uptime ticks - number of ticks at last input IdleTicks = systemUptime - LastInputTicks EndIf LastInputInfo = BinaryFree(LastInputInfo) ;Convert milliseconds to seconds SystemUptime = systemUptime / 1000 IdleTime = IdleTicks / 1000 LastInput = LastInputTicks / 1000 Return IdleTime #EndFunction ;Wait For No user input for 10 seconds BoxOpen('Check for user input','') While @TRUE tick = Idle_Tick() If tick==10 Pause('Notice','No user input for 10 seconds!') EndIf BoxText('No user input for ':tick:' seconds') TimeDelay(1) EndWhile
Article ID: W17403
File Created: 2011:09:01:09:34:10
Last Updated: 2011:09:01:09:34:10