#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(

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
While @TRUE
tick = Idle_Tick()
If tick==20
currentwin = WinGetActive()
WinClose(currentwin)
TimeDelay(5)
Run("Chrome","-incognito")
TimeDelay(1)
EndIf
EndWhile