Kibbz92 Posted May 19, 2014 Share Posted May 19, 2014 #include <timers.au3> #include <Misc.au3> if _Timer_GetIdleTime() > 5000 Then run("notepad") _Singleton("notepad") EndIf If _Timer_GetIdleTime() < 500 Then ProcessClose("notepad") EndIf 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 More sharing options...
Solution FireFox Posted May 19, 2014 Solution Share Posted May 19, 2014 Hi, 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") EndIf If $iPid > 0 And _Timer_GetIdleTime() < 500 Then ;if notepad is opened ;and the user isn't idle ProcessClose($iPid) $iPid = 0 EndIf WEnd 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. Kibbz92 1 Link to comment Share on other sites More sharing options...
Kibbz92 Posted May 19, 2014 Author Share Posted May 19, 2014 thanks FireFox, its works great! Link to comment Share on other sites More sharing options...
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