Jump to content

Process exists then stop exec.


Recommended Posts

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...