How to Launch an Exe after a Period of Inactivity
Keywords: screensaver
Question:
I would like to launch an exe file after
10 minutes of inactivity (no mouse / keyboard input). Is there an efficient way
using WIL to achieve this. Or alternatively,
is there a way I could utilize Windows
screen saver to do this ? ie, set the screen
saver to ten minutes and somehow get it to
launch my exe file.
Answer:
I used to do a very similar thing on a bunch of workstations. Here's what I did:
- Set the screen saver configuration to a "known" screen saver program like the marquee screen saver.
- Figure out what the window name is that the screen saver opens when it is running.
- Have a WinBatch script running [hidden] in the background that does a WinWaitExist() on this window
name. You might want a long timeout period like 20 to 30 seconds or you might request that WinWaitExist()
never time out at all. Also, be sure that you've used the appropriate IntControl(...) calls to allow your script
to be terminated silently if Windows shuts down while the script is waiting for a response.
- When the screen saver gets launched due to inactivity on the part of the user, your script wakes up
because WinWaitExist returns success. At this point your script can use any of the Run*() functions to
launch another program that needs to run while the workstation is inactive.
To find the name of the screensaver:
TimeDelay(300) ; long enough for screen saver to go off
list=WinItemize()
askItemList("Windows",list,@tab,@unsorted,@single)
although it's possible that it window title isn't listed because Windows doesn't require that...
Article ID: W15172
File Created: 2002:09:05:13:50:16
Last Updated: 2002:09:05:13:50:16