Jump to content
Sign in to follow this  

need help with idle timer

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 :) 




Share this post

Link to post
Share on other sites

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.


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control


Share this post

Link to post
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
Sign in to follow this  

  • Create New...