Thursday, June 5, 2008

Monitor Standby Script Causes Problems Coming Out of Hibernation (Autohotkey)

One of my oldest, most favorite Autohotkey scripts had been a small, simple, piece of code that put the monitor on standby. It let me shut down my computer without forgetting to shut down the monitor (which I often did). However, recently I found out this piece of code had been the reason I was having a problem getting Windows XP to come out of hibernate.

The problem was that when I run my Autohotkey script to hibernate the computer (after running some utilities), sometimes when I come back and turn the computer on, it powers up but the OS never loads. The monitors show that it never gets a signal. I would have no choice but to unplug the computer altogether and then start it up again (sometimes it would return from its hibernate state, sometimes not).

Because of this problem, I'd begun only putting my computer on Standby instead of hibernate. However, out of a nagging need to be someone environmentally and energy conscious, I wanted to go back to hibernation, and went to figure out what the problem was.

The problem seems to have something to do with whether or not I shut down the monitors manually anyway; something trips up when the Autohotkey script tries to put monitors on standby that it can't find are on to begin with. Here is the offending code:

#m:: ; Win+M hotkey that turns off the monitor.
Sleep 1000 ; Give user a chance to release keys (in case their release would wake up the monitor again).
; Turn Monitor Off:
SendMessage, 0x112, 0xF170, 2,, Program Manager ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
; Note for the above: Use -1 in place of 2 to turn the monitor on.
; Use 1 in place of 2 to activate the monitor's low-power mode.
For the moment, I just went ahead and deleted this code from my hibernate script, and I have had no problems yet. I'll just have to remember to shut the monitors down myself. If you know a workaround for this problem, do let me know!

Related Posts by Categories

Widget by Hoctro | Jack Book

1 comment:

nrk112 said...

Try changing sendmessage to postmessage. I dont know if that will fix anything but sendmessage waits for an answer while post just sends and is done with it.