Jump to content

AutoIt and KeePass


somdcomputerguy
 Share

Recommended Posts

I wrote this script to use with KeePass, a password manager that I have used for almost forever. This script isn't meant to replace the hot-keys, but to just provide another way to execute them. I'm sure there are at least a few other users of this password manager, and this script is really small and it shouldn't be hard to understand, so feel free to use it and ask any questions about it. Oh, I start this script with a trigger in KeePass.

 

Opt("TrayMenuMode", 3)

Local $SleepTime   = 100
Local $helpURL     = "https://keepass.info/help/base/index.html"
Local $KeePass[2]  = ["C:\Program Files\KeePass Password Safe 2\", "KeePass.exe"]
Local $AutoType[3] = ["-auto-type", "-auto-type-password", "-auto-type-selected"]

Local $idKP   = TrayCreateItem("KeePass")
Local $idKPH  = TrayCreateItem("KeePass Help")
 TrayCreateItem("")
Local $idAT   = TrayCreateItem("AutoType Selected")
Local $idGAT  = TrayCreateItem("Global AutoType")
Local $idGATP = TrayCreateItem("Global PassWord")
 TrayCreateItem("")
Local $idExit = TrayCreateItem("Exit")

If $CmdLine[0] > 1 Then
 For $i = 1 to $CmdLine[0]
  Switch $CmdLine[$i]
   Case '-delay'
    $SleepTime  = $CmdLine[$i + 1]
   Case '-path'
    $KeePass[0] = $CmdLine[$i + 1]
   Case '-name'
    $KeePass[1] = $CmdLine[$i + 1]
  EndSwitch
 Next
EndIf

TraySetState(1)
TraySetIcon(@ScriptDir & '\AutoGAT.ico')

While 1
    If Not ProcessExists($KeePass[1]) Then ExitLoop ;leaves this While loop if KeePass exits or isn't running
    Switch TrayGetMsg()
        Case $idExit
            Exit
        Case $idKP
            ShellExecute($KeePass[0] & $KeePass[1])
        Case $idKPH
            ShellExecute($helpURL)
        Case $idAT
            Send("!{TAB}")
            Sleep($SleepTime)
            ShellExecute($KeePass[0] & $KeePass[1], $AutoType[2])
           Case $idGAT
            Send("!{TAB}")
            Sleep($SleepTime)
            ShellExecute($KeePass[0] & $KeePass[1], $AutoType[0])
        Case $idGATP
            Send("!{TAB}")
            Sleep($SleepTime)
            ShellExecute($KeePass[0] & $KeePass[1], $AutoType[1])
    EndSwitch
WEnd

Exit

 

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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

×
×
  • Create New...