Skip to content

Instantly share code, notes, and snippets.

@solariz
Created May 23, 2018 09:43
Show Gist options
  • Save solariz/9fd8f0c58d15aaf3776e520ec82e5e83 to your computer and use it in GitHub Desktop.
Save solariz/9fd8f0c58d15aaf3776e520ec82e5e83 to your computer and use it in GitHub Desktop.
; KeePassXC AutoIt3 Script to give the possibility to activate KeePassXC by HotKeySet
; Currently tested with Win10 x64 and KeePassXC 2.3.3
; CTRL-ALT-k will toggle KeePassXC (if in tray)
; if KeePassXC is focused ESC Key will minimize it to Tray
;
; feel free to improve this script
; www.solariz.de
;
#Include <GuiToolBar.au3>
HotKeySet("^!k", "ShowKeePassXC") ; Ctrl-Alt-k
HotKeySet("{Esc}", "captureEsc")
While 1
Sleep(500)
WEnd
func captureEsc()
; if KeePassXC is focused toggle window minimize
if StringInStr(WinGetTitle("[ACTIVE]"),"KeePassXC") Then
ShowKeePassXC()
EndIf
EndFunc
func ShowKeePassXC()
$hSysTray = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Text:User Promoted Notification Area]');
For $i = 1 To _GUICtrlToolbar_ButtonCount($hSystray)
; KeePassXC do not set a button text so we need to use some trick
$sCurrent = _GUICtrlToolbar_GetButtonText($hSystray,$i)
if $sCurrent = "" Then
$sCurrent = _GUICtrlToolbar_GetButtonBitmap($hSystray,$i)
;ConsoleWrite($i & ": " & $sCurrent & @CRLF)
If $sCurrent = 13 Then
_GUICtrlToolbar_ClickButton($hSystray, $i, "left")
WinWaitActive("[CLASS:Qt5QWindowIcon]", "")
send("^f")
ExitLoop
EndIf
EndIf
Next
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment