Sign in to follow this  
Followers 0
RogFleming

ProgramWatcher

1 post in this topic

the purpose of this code was in a situation where the user might use one main program on a computer and when they close the program they want the computer to lock. Works very well in an environment where many people might share workstations, or you need to get away from the pc quickly.

Syntax programwatcher.exe path executable args

Example:

Programwatcher.exe c:\windows notepad.exe test.txt (with args)

Programwatcher.exe c:\windows notepad.exe (without args)

#include <File.au3>
$var1 = $cmdline[1]
$var2 = $cmdline[2]
$var3 = $cmdline[3]
$program_dir_path = $var1
$program_exe_name = $var2
$program_args = $var3

IF $var3 = "" Then
        If FileExists($var1 & "\" & $var2) Then
            ProcessWaitClose($var2)
            ; This will wait until this particular instance of notepad has exited
            $PID = Run($var1 & "\" & $var2)
            $closeapp = ProcessWaitClose($PID)
            Send ("{LWINDOWN} + {l}",0)
            Exit
        EndIf
Else
        If FileExists($var1 & "\" & $var2) Then
            ProcessWaitClose($var2)
            ; This will wait until this particular instance of notepad has exited
            $PID = Run($var1 & "\" & $var2 & " " & $var3)
            $closeapp = ProcessWaitClose($PID)
            Send ("{LWINDOWN} + {l}",0)
            Exit
        EndIf
EndIf
Exit

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  
Followers 0