I use these two shortcuts to turn off the display:

#T:: SendMessage, 0x112, 0xF170, 2,, Program Manager

However, not infrequently, the display turns back on instantly after I use this hotkey. I press it again four to seven times, and it turns back on again. Then, I adjust the mouse a bit and try turning off. Sometimes, it works and sometimes, it doesn't.

Also, if I use the 'Launch_Mail' button to turn off the display and it doesn't, I use the '#T' shortcut. Most of the time, this works, but there are also times when that doesn't work either.

Is the problem with the mouse or something else? Should I also disable the mouse at the time of turning off the display.

I tried searching for this problem, but I couldn't find anything that was similar to my situation.

I don't know if this is much relevant, but I use Windows 8.1 and AHK v1.1.22.06


Since it appears you're using the script from here: https://autohotkey.com/docs/commands/PostMessage.htm which provides the following code:

#o::  ; Win+O 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.

I have to ask: Are you using the full script, or only that one line, because per the comments, -1 should be turning the monitor back on, suggesting your script might be running the off and on commands back to back.

  • 1
    I was using only that line. I've changed that. So, that shouldn't create any problem now. Thanks for the feedback. :) – user313811 Feb 14 '16 at 1:29
  • @Mahesh Glad to help! – David Metcalfe Feb 14 '16 at 1:38

It is probably the release of the hotkey(s) that turns the display on again. This can be solved either by a "timeout", as in David Metcalfe's answer, or by simply waiting until the hotkey is released and only then turning the display off. The idiomatic way to do this is to use the up modifier (see the documentation).

Launch_Mail Up::
#T Up:: SendMessage, 0x112, 0xF170, 2,, Program Manager

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.