AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A_TimeIde and A_TimeIdlePhysical problem

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
pvi



Joined: 31 Mar 2008
Posts: 6

PostPosted: Fri Apr 04, 2008 6:55 am    Post subject: A_TimeIde and A_TimeIdlePhysical problem Reply with quote

I want my computer to suspend after 30 min of inactivty, so I wrote the following script:

Code:

#Persistent
SetTimer, CheckShutdown, 60000
return

CheckShutdown:
   if A_TimeIdle > 1800000
   DllCall("powrprof.dll\SetSuspendState","Int",0)
return


This works fine when I only have one active user on the system, but when I run this script under user1 and user2 is the active user, the A_TimeIdle is not resetted, although mouse and keyboard are used (so computer suspends every minute).

I also tried A_TimeIdlePhysical, but this is not resetted with mousemoves, only with keypresses.

I'm running under Vista.

Anyone any clues how to solve this?
_________________
Paul Vintges
Back to top
View user's profile Send private message
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Fri Apr 04, 2008 7:08 am    Post subject: Reply with quote

A_TimeIdle in manual wrote:
This variable will be blank unless the operating system is Windows 2000, XP, or beyond.


Maybe Vista too? Rolling Eyes

Code:
SetTimer, Check, 60000
Return

Check:
If (A_TimeIdlePhysical > (180 * 1000)) {
   MsgBox, You have been idle for more than 3 minutes.
}


^^Should work, not tested^^
Back to top
View user's profile Send private message
pvi



Joined: 31 Mar 2008
Posts: 6

PostPosted: Fri Apr 04, 2008 7:16 am    Post subject: Reply with quote

No, it does contain values, and it also works ok with just a single user (or when the user under which the script is running is the active user), the problem is that A_TimeIdle doesnt reset when another user is the active user.
_________________
Paul Vintges
Back to top
View user's profile Send private message
pvi



Joined: 31 Mar 2008
Posts: 6

PostPosted: Fri Apr 11, 2008 6:11 pm    Post subject: Reply with quote

I was able to solve this in a rather dirty way, but it works.

On the main user automatically start autohotkey with the following script:
Code:

#Persistent
SetTimer, CheckShutdown, 300000 ; Check every 5 mins
return

CheckShutdown:
if A_TimeIdle >= 1500000 ; after 25 mins idle time
{
  IfExist, C:\Idle.txt
  {
    FileDelete E:\Idle.txt
    DllCall("powrprof.dll\SetSuspendState","Int",0)
  }
  else
  {
    FileAppend, , E:\Idle.txt
  }
}
else
  FileDelete E:\Idle.txt

return


On all other users automatically start Autohotkey with folowing script:
Code:

#Persistent
SetTimer, CheckShutdown, 240000 ; Check every 4 mins
return

CheckShutdown:
if A_TimeIdle <= 1800000 ; If this user is not idle for 30 mins yet
{
  IfExist, E:\Idle.txt
  {
    FileDelete E:\Idle.txt
  }
}
return

_________________
Paul Vintges
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group