How to Detect Idle Workstation
Keywords: detect idle
Question:
I was wondering if anyone knows of a way to detect how long a workstation has been Idle (no keys pressed and no mouse movement) using WinBatchAnswer:
No perfect way...but if you get the mouse position with one of the MouseInfo functions and the active Window with the WinGetActive function, put it in a loop and clear your counter if anything changes, it's a pretty good sign someone is using the computer. IsKeyDown might help too...And after an idle of about 5 minutes it continues the script.
Ummm somthing like (undebugged code here)
while 1 ; timing loop idle=0 mouse=MouseInfo(2) wnd=WinGetActive() while 1 ; inside detect loop if IsKeyDown(@SHIFT|@CTRL) then break if mouse!=MouseInfo(2) then break if wnd!=WinGetActive() then break TimeDelay(1) ; adjust resolution idle=idle+1 ; adjust here also if idle==300 then break endwhile if idle=300 then break ; yes again endwhile Message("Ooop","Workstation idle for 300 seconds")The other way is to detect when the screen blanker goes off and deal with that.
Article ID: W13144Filename: Detect if Workstation is Idle.txt