Page 1 of 1

Turn off monitor combo

Posted: 14 Jun 2019, 21:06
by Cionn
I'm trying to use a combination of appskey & left arrow key to turn off the monitor. The script below works but when I release the keys the monitor turns on. How can I make it so that code executes on release instead of press of appskey & left arrow key combination ??

Code: Select all

Appskey & left::
   	SendMessage 0x112, 0xF170, 2, , Program Manager
Return
[Mod edit: Topic moved to 'Ask for Help']

Re: Turn off monitor combo  Topic is solved

Posted: 14 Jun 2019, 21:27
by wolf_II
Try this:

Code: Select all

Appskey & left up::
   	SendMessage 0x112, 0xF170, 2, , Program Manager
Return
I hope that helps.

Re: Turn off monitor combo

Posted: 14 Jun 2019, 21:29
by gregster
Cionn wrote:
14 Jun 2019, 21:06
The script below works but when I release the keys the monitor turns on. How can I make it so that code executes on release instead of press of appskey & left arrow key combination ??
Well, on my system, that doesn't happen, but you could try to use Up:

Code: Select all

Appskey & left up::
	SendMessage 0x112, 0xF170, 2, , Program Manager
Return
This works too on my system (but then again, it works already without it).

But the docs recommend a sleep instead, in a case like this, to prevent the effect you describe: Please see this example: https://www.autohotkey.com/docs/commands/PostMessage.htm#Examples

Code: Select all

#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.
return
Or, try to combine both ;)

Re: Turn off monitor combo

Posted: 14 Jun 2019, 23:25
by Cionn
Thanks a lot everyone.
That worked