silber Posted January 31, 2020 Posted January 31, 2020 (edited) Probably something simple, but i'm trying to create a trigger that happens if the user is idle for too long (in this example 10 seconds). #include <Timers.au3> While 1 $CurrIdleTime = _Timer_GetIdleTime() Switch $CurrIdleTime Case $CurrIdleTime >= 10001 MsgBox(64,"Current Idle Time",$CurrIdleTime) Exit EndSwitch WEnd So if I run this and don't press anything the message box will trigger in 10 seconds, but if press anything the message box will immediately trigger. The $CurrIdleTime given to me in the message box always reads 0 in the second scenario, so I'm not understanding why the case would trigger if it's clearly not greater than or equal to 10001. Does moving the mouse/pressing a key cause _Timer_GetIdleTime() to very quickly go to another value than zero? I tried specifying Number($CurrIdleTime), but it didn't make any difference. Any insight would be appreciated, thank you. Edited January 31, 2020 by silber solved
AdamUL Posted January 31, 2020 Posted January 31, 2020 You are using Switch incorrectly, use Select or If instead. #include <Timers.au3> While 1 $CurrIdleTime = _Timer_GetIdleTime() Select Case $CurrIdleTime >= 10001 MsgBox(64,"Current Idle Time",$CurrIdleTime) Exit EndSelect WEnd Adam
silber Posted January 31, 2020 Author Posted January 31, 2020 Ahh, figured I must be doing something dumb. Much obliged.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now