WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System Info

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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 WinBatch

Answer:

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:   W13144
Filename:   Detect if Workstation is Idle.txt
File Created: 2001:03:01:12:18:00
Last Updated: 2001:03:01:12:18:00