Jump to content

Recommended Posts

  • Solution
Posted

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.

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...