Here's the script in case you find it useful:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.10.2
Author: Michael Gerrard, http://mgxp.blogspot.com
Script Function:
Close a process
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
$title = "Close Java"
$proc = "jp2launcher.exe"
If ProcessExists($proc) > 0 Then ;if it is running...
; Confirm that it should be closed
$ok = MsgBox(33, $title, "Close " & $proc & "?")
If $ok = 1 Then ;if OK
While ProcessExists($proc) > 0
ProcessClose($proc)
Sleep(500) ;pause half a second
Wend
Else ;if Cancel
Exit
EndIf
; Check again to see if it is running now...
If ProcessExists($proc) > 0 Then ;it is still running
MsgBox(0, $title, "Failed!")
Else ;it is not running
MsgBox(0, $title, "Success!")
EndIf
Else ;if it is not running...
MsgBox(0, $title, $proc & " is not running")
EndIf
Exit
Copy the above code, save it in a text file called CloseJava.au3
Compile using AutoIt https://autoitscript.com
Double click the resulting CloseJava.exe, it'll say:
Click OK
Conclusion
Just a small script that demonstrates how useful AutoIt is. Of course I've shown how to close Java but you could use the same script to close a different program. Just alter the $proc= variable.
No comments:
Post a Comment