May 17, 2021

Quick Login with AutoHotkey

In this post I share a AutoHotkey script for quickly logging in.
I had some troubles last week to log in (single-sign-on wasn't working) and came to adapt my AutoHotkey TextExpander script that already contains a hotkey for typing my password, to also fill in the login form (username and password)

This is very simple and looks like this:

!l:: ; <--- Login
Clip_Paste(A_UserName)
SendInput {Tab}
sPassword := Login_GetPassword()
Clip_Paste(sPassword)
SendInput {Enter}
return

The Login_GetPassword function looks like this:

; ----------------------------------------------------------------------
Login_GetPassword(){
static sPassword
If !(sPassword = "")
    return sPassword

InputBox, sPassword, Password, Enter Password for Login, Hide, 200, 125
If ErrorLevel
    return
return sPassword
}

This simply paste the username (take from the environment variable A_UserName) , Tab and paste the Password followed by ENTER.
Clip_Paste function is available in the ahk/Lib/Clip.ahk

See also

Handling of Password storage in AutoHotkey | Thierry Dalon's Blog

AutoHotkey: Paste and restore clipboard pitfall | Thierry Dalon's Blog

No comments:

Post a Comment