AutoHotkey Community

It is currently May 27th, 2012, 5:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: September 21st, 2010, 5:59 pm 
Hi,

I tried to shutdown my computer if it idles for more than 1min but nothing works please advice thanks.

Code:
#persistent

settimer, shutdown, 10000

shutdown:
 if A_TimeIdlePhysical > 5000
{
shutdown, 13
}
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2010, 6:19 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
Well, the time is in ms, so a minute is 60000, not 5000 (5 seconds).

I'm not sure how well 13 would work (Shutdown, Force, Powerdown). perhaps just 12? (Force PowerDown)

Out of habit i surround my if statements in ()'s, which forces it to take it as an expression, although i am not sure how much difference that makes.

Lastly, i don't recommend using a label/variable that has the same name as a function.

So..

Code:
#persistent

settimer, turnoff, 1000 ;every second

turnoff:
;if over a minute...
 if (A_TimeIdlePhysical > 60000)
    shutdown, 8 + 4 ;force powerdown
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2010, 6:38 pm 
Hi but it does not work nothing happen and all the logs show is this and it goes forever. Anyone else know whats the problem?

003: SetTimer,turnoff,1000
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)
007: if (A_TimeIdlePhysical > 60000)
010: Return (1.00)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2010, 6:45 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
Maybe add a tooltip? Although it says any physical activity would reset the time.... Do you have an optical mouse? I notice sometimes my mouse moves on it's own for no reason (Drifting left or whatnot).

Code:
;as before
tooltip, Idle: %a_TimeIdlePhysical%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2010, 6:50 pm 
Problem solved must use hooks but thanks anyways

Code:
#persistent
#InstallKeybdHook
#InstallMouseHook

settimer, turnoff, 1000 ;every second

turnoff:
;if over a minute...
 if (A_TimeIdlePhysical > 60000)
    shutdown, 8 + 4 ;force powerdown
return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, batto, Bing [Bot], dra, HotkeyStick, mKnight, sjc1000, Wicked, XstatyK 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