smcombs Posted March 21, 2009 Share Posted March 21, 2009 Ok I am writing a script that will use my Kee Pass database to auto enter in my username and password by hotkeys. I got all that squared away. What I am stuck on is stopping the execution of the script if the process exists or not. However I need this to run before the exe actually starts is this possible? And I know Kee Pass has global hotkeys but I dont want to use them. Here is the code: CODE#include <Misc.au3> _Singleton("KeeEnterInfo.au3") AutoItSetOption("WinTitleMatchMode", 4) HotKeySet("^l", "Exec") HotKeySet("^g", "Gettitle") HotKeySet("{ESC}", "Terminate") If ProcessExists("KeeEnterInfo.exe") Then Exit EndIf While 1 Sleep(500) If WinExists("database.kdbx - KeePass Password Safe") Or WinExists("Open Database - database.kdbx") Then Else ShellExecute("C:\Program Files\KeePass Password Safe\KeePass.exe") sleep(500) WinActivate("Open Database - database.kdbx") EndIf WEnd Func Exec() $t = WinGetTitle("[ACTIVE]", "") ControlSend("database.kdbx - KeePass Password Safe", "", "WindowsForms10.SysListView32.app.0.33c0d9d1", $t) WinActivate("database.kdbx - KeePass Password Safe") ControlSend("database.kdbx - KeePass Password Safe", "", "WindowsForms10.SysListView32.app.0.33c0d9d1", "^v") WinSetState("database.kdbx ", "", @SW_MINIMIZE) EndFunc Func Gettitle() $t = WinGetTitle("[ACTIVE]", "") ControlSend("Add Entry", "", "WindowsForms10.EDIT.app.0.33c0d9d4", $t) EndFunc Func Terminate() Exit EndFunc And I was able to stop the script from starting twice but I also want to make it so the process is not running multiple times even if a user tries to run the .exe again. Is there a piece of code that will allow me to check the process status before actually starting the process. Heh, sounds kinda rediculous. Link to comment Share on other sites More sharing options...
Spiff59 Posted March 21, 2009 Share Posted March 21, 2009 This work for you? If _Singleton (@ScriptName, 1) = 0 Then ProcessClose(@ScriptName) Link to comment Share on other sites More sharing options...
smcombs Posted March 21, 2009 Author Share Posted March 21, 2009 Yes!! That works awesome thank you so much. Flawless too!! Link to comment Share on other sites More sharing options...
Spiff59 Posted March 21, 2009 Share Posted March 21, 2009 Actually, maybe that's not what you want? That was the form that kills the existing instance of the script and lets the second one run. If you want to block the second script, keeping the first then just "_Singleton(@ScriptName,0)" ought to do you. 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