AutoHotkey Community

It is currently May 26th, 2012, 5:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: April 5th, 2008, 2:15 am 
Offline

Joined: April 5th, 2008, 2:08 am
Posts: 4
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 April 15th, 2008, 1:49 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2008, 6:52 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2008, 11:42 am 
Offline

Joined: April 5th, 2008, 2:08 am
Posts: 4
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 :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2008, 9:48 pm 
Like the Nike slogan implies: Just do it!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 2:24 am 
Offline

Joined: April 5th, 2008, 2:08 am
Posts: 4
Quote:
Like the Nike slogan implies: Just do it!

Some trial and error and actually I did do it! :D
A simple loop with the getkeystate solved my problem.
Any way, thanks for your help


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 2:57 am 
No prob :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 3:29 am 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
Please post your script, seems interesting.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2008, 1:48 am 
Offline

Joined: April 5th, 2008, 2:08 am
Posts: 4
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,


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2008, 1:57 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
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.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Google [Bot], mrhobbeys, poserpro, rbrtryn, tank and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group