1

Does Windows send any sort of message or command that can be interpreted by AutoHotKey to run a particular script AS the screensaver is about to activate? Example: my DVR software freezes/locks up my computer if it runs while the screensaver is active. I would like for AHK to close that window when the screensaver turns on, as this is controlled by Group Policy and not me locally.

I know I could create an AHK script that closes the window after 9 min of inactivity, but I would like to link it to the Windows activation of the screensaver if possible. Please advise! I have checked thru Google, SO, and the AHK docs. Thanks.

  • I'm afraid there's no such event; is there an event that fires when a process is launched? – John Dvorak Dec 26 '12 at 22:18
  • How about activating your own "screensaver" by monitoring keyboard/mouse activity + checking which window is open and blanking your screen (nircmd.exe" monitor off) through AHK when YOU want it? – Robert Ilbrink Dec 27 '12 at 06:34

1 Answers1

1

If you want to move your mouse 1 pixel back/forth you can use:

SetTimer, MoveMouse, 60000 ; Move mouse every 60 seconds

MoveMouse:
    MouseMove, 1, 0, 1, R ;Move the mouse one pixel to the right
    Sleep, 50 ; Wait 50 ms. Not realy required, but makes the move visible
    MouseMove, -1, 0, 1, R ;Move the mouse back one pixel
return

This will circumvent the system / group policy defined screensaver and allow you to define when the screensaver will kick-in. Moving the mouse 1 pixel back / forth is enough to stop the screensaver and is hardly noticeable. You can stop the timer at any time with the

SetTimer, MoveMouse, Off

Command (I think that any running timers are not affected by setting this to Off).

Robert Ilbrink
  • 7,738
  • 2
  • 22
  • 32
  • Thanks Robert for your input on this. I did find that documentation via a Google search, but I was wondering specifically if there is a way to get AHK to detect or listen for when the screensaver program starts running. Maybe it's not even as complicated as an event firing when that happens - maybe AHK can check every 5 seconds to see if scrnsvr.exe is running, and if it is, perform the action in the script ONCE (closing the DVR software window). Do you know of anything like that? If not, I will write the script as above, so thanks for the useful information either way. – theAliasOfAlias Dec 28 '12 at 17:25
  • Did you check this? http://stackoverflow.com/questions/3953297/detecting-if-the-screensaver-is-active-and-or-the-user-has-locked-the-screen-in?answertab=oldest#tab-top. It's not AutoHotKey but it is a a start. – Robert Ilbrink Dec 31 '12 at 09:24
  • Thanks Robert, I will look into it. In the meantime, guess I'll have to go with the solution you proposed above. Thanks! – theAliasOfAlias Jan 02 '13 at 19:14
  • in reference to https://autohotkey.com/board/topic/13510-move-mouse-when-not-in-use-to-disable-screensaver/ – Bernhard May 19 '16 at 08:07
  • #Bernhard, Thank you for enhancing the discussion with additional information. – Robert Ilbrink May 22 '16 at 10:37