 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Matrix
Joined: 05 Apr 2008 Posts: 4
|
Posted: Sat Apr 05, 2008 1:15 am Post subject: [SOLVED-partly]Keep Screen Off Unless A Specific Key Pressed |
|
|
Hello!
I have used the following code to turn off my monitor:
| Code: | #o::
Sleep 01000
SendMessage, 0x112, 0xF170, 1,, Program Manager
return |
I also want to add functionality that keeps the monitor off unless space bar or some other key is pressed, BUT all other keys keep operating normally.
The reason I want to do this, is that I can continue to control Winamp even when the monitor is off.
Help is appreciated!
Last edited by Matrix on Tue Apr 15, 2008 12:49 am; edited 2 times in total |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Sun Apr 06, 2008 5:52 am Post subject: |
|
|
How about changing the Display Properties so that the output is not going to the laptop's LCD? For example, switch to the VGA port (where there presumably is no monitor). I think that would achieve the desired effect. _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Matrix
Joined: 05 Apr 2008 Posts: 4
|
Posted: Sun Apr 06, 2008 10:42 am Post subject: |
|
|
jaco0646 thanks for your reply.
If I am getting you correctly, you mean creating a script which actually does the same as fn+F5?
Help will be appreciated in creating the script  |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Apr 08, 2008 8:48 pm Post subject: |
|
|
| Like the Nike slogan implies: Just do it! |
|
| Back to top |
|
 |
Matrix
Joined: 05 Apr 2008 Posts: 4
|
Posted: Wed Apr 09, 2008 1:24 am Post subject: |
|
|
| Quote: | | Like the Nike slogan implies: Just do it! |
Some trial and error and actually I did do it!
A simple loop with the getkeystate solved my problem.
Any way, thanks for your help |
|
| Back to top |
|
 |
Troll Guest
|
Posted: Wed Apr 09, 2008 1:57 am Post subject: |
|
|
No prob  |
|
| Back to top |
|
 |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Wed Apr 09, 2008 2:29 am Post subject: |
|
|
| Please post your script, seems interesting. |
|
| Back to top |
|
 |
Matrix
Joined: 05 Apr 2008 Posts: 4
|
Posted: Tue Apr 15, 2008 12:48 am Post subject: |
|
|
After further investigating the script I wrote, I saw it wasn't a good script.
Meaning, while the script was in the loop, the CPU usage climbed to 50%.
The logic of the script was to keep sending the command to shutdown the monitor till one of the keys (space, left mouse button, right mouse button) were pressed:
| Code: | ^esc:: ; ctrl+esc 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).
Loop
{
; Turn Monitor Off:
SendMessage, 0x112, 0xF170, 1,, 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
If ((GetKeyState("Space","P")) Or (GetKeyState("LButton","P")) Or (GetKeyState("Rbutton","P")))
{
SendMessage, 0x112, 0xF170, -1,, Program Manager
break
}
}
return |
If anyone knows a way to boost this script into a better one, I would appreciate it.
Thanks, |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1494
|
Posted: Tue Apr 15, 2008 12:57 am Post subject: |
|
|
| Code: | ^esc:: ; ctrl+esc 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).
Loop
{
; Turn Monitor Off:
Sleep 1000
If A_TimeIdlePhyiscal < 2500
{
SendMessage, 0x112, 0xF170, 1,, 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
If ((GetKeyState("Space","P")) Or (GetKeyState("LButton","P")) Or (GetKeyState("Rbutton","P")))
{
SendMessage, 0x112, 0xF170, -1,, Program Manager
break
}
}
}
return |
That should cut down on CPU load and only turn off the monitor a few seconds after the user has done some input. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|