Turn off monitor combo Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Cionn
Posts: 4
Joined: 25 Jun 2016, 08:30

Turn off monitor combo

14 Jun 2019, 21:06

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']
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Turn off monitor combo  Topic is solved

14 Jun 2019, 21:27

Try this:

Code: Select all

Appskey & left up::
   	SendMessage 0x112, 0xF170, 2, , Program Manager
Return
I hope that helps.
gregster
Posts: 3028
Joined: 30 Sep 2013, 06:48

Re: Turn off monitor combo

14 Jun 2019, 21:29

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 ;)
Cionn
Posts: 4
Joined: 25 Jun 2016, 08:30

Re: Turn off monitor combo

14 Jun 2019, 23:25

Thanks a lot everyone.
That worked

Return to “Ask For Help”

Who is online

Users browsing this forum: DRocks, flyingDman, Xtra and 64 guests