Jump to content

need help with idle timer

Go to solution Solved by FireFox,

Recommended Posts

#include <timers.au3>
#include <Misc.au3>

if _Timer_GetIdleTime() > 5000 Then
    run("notepad") _Singleton("notepad")
If _Timer_GetIdleTime() < 500 Then

noob here, im having trouble with my script to open notepad after being idle then closing notepad when user activity is detected. heres my code, thanks for any help u can give me :) 




Link to comment
Share on other sites

  • Solution

Welcome to the autoit forum :)

#include <Timers.au3>
#include <Misc.au3>

Global $iPid = 0
While 1 ;loop to constantly check conditions
    If ($iPid = 0 Or ProcessExists($iPid) = 0) And _Timer_GetIdleTime() > 5000 Then ;if notepad isn't opened
;and the user is idle for more than 5secs
        $iPid = Run("notepad")
    If $iPid > 0 And _Timer_GetIdleTime() < 500 Then ;if notepad is opened
;and the user isn't idle
        $iPid = 0

Note : _Singleton can not be used here to avoid reopening a process, it can only be used for your own script unless you know the target process is using the function with the "occurrence identifier".

Br, FireFox.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...