AutoHotkey Community

It is currently May 27th, 2012, 11:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: MonitorIdle
PostPosted: January 31st, 2012, 12:42 pm 
Offline

Joined: December 9th, 2011, 9:10 pm
Posts: 6
The following script will turn off the screen at 10 secs of being idle, not 9, not 11. The script will check the value of A_TimeIdlePhysical, and will wait the remaining time to get the value entered at the variable IdleTimeSet.

Once the 10 secs are passed without moving the mouse or pressing a key, it will show a message telling you it will turn off the screen in 2 seconds, to abort it, simply move the mouse or press a key.

I wrote it to use it when listening music. Hope you like

Code:
;lnminente 2012 01 31
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;Menu, Tray, Icon, D:\Documents\Pictures\monitor-off-icon.ico
IdleTimeSet := 10000 ; 10 segundos para apagar la pantalla

Loop{

IF abs( IdleTimeSet - A_TimeIdlePhysical ) < 100 ;Tolerancia de +-100ms
{
UntilIdle := IdleTimeSet
splashTextOn, , , En 2 segundos se apagara la pantalla
Sleep 2000

IF A_TimeIdlePhysical > 2000
{
SendMessage, 0x112, 0xF170, 2,, Program Manager  ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
}
else
{
UntilIdle := IdleTimeSet - A_TimeIdlePhysical
}
splashTextOff
}
else
{

IF IdleTimeSet - A_TimeIdlePhysical > 0
UntilIdle := IdleTimeSet - A_TimeIdlePhysical

}
;splashTextOn, , , Until: %UntilIdle%  Idle:%A_TimeIdlePhysical%
Sleep UntilIdle

}
return
 


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2012, 11:44 pm 
Offline

Joined: July 18th, 2010, 12:02 am
Posts: 16
You probably have your use for a twelve second monitor standby but I can't imagine it.

You might also want to look at SetTimer. That will probably be more efficient than looping through your conditions thousands of times per second.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 12:52 am 
Offline

Joined: December 9th, 2011, 9:10 pm
Posts: 6
I was thinking in making the screen of my laptop work like my phone, turning off the screen after 10 seconds of being idle (Really 12 seconds considering the message to abort it). I only enable it when running on battery and listening music.

Yep! The real interest of my script could be wich it avoids thousand of loops. Instead of that, it simply wait the needed time before looping again. I wrote it thinking in saving some CPU time, but i have to say i didn't verify if it actually saves CPU.

Anyway, it could be easy to create a function to use this way of looping...


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug, nomissenrojb, Rajat and 60 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