I'm trying to sign onto my VPN with a hotkey, which means running the program, tabbing through the fields (all of them auto-populated), and pressing "Enter" once you've tabbed onto the "Submit" field.
I couldn't get it working at first (I'm very new to AHK) so I started testing it out on Notepad as I found it easier to see where things were going wrong that way. Anyway, I ended up with the following script, which works perfectly:
#!n::
Run Notepad.exe
WinActivate Untitled - Notepad
WinWaitActive Untitled - Notepad
Send {Tab 8}
Send {Enter}
return
But it's not working for my VPN. I have managed to get it working for the VPN by splitting it across two stanzas like this:
#!f::
Run [file address omitted]
return
#!o::
WinActivate [window title omitted]
WinWaitActive [window title omitted]
Send {Tab 8}
Send {Enter}
return
I'd really rather have it all encompassed in a single hotkey, though. Any advice would be appreciated!
Thanks.
WinActivate
, the VPN still hasn't started, so it does nothing, and thus your program hangs on theWinWaitActive
. You could use aWinWait
before theWinActivate
to prevent this behavior. Also, from the docs, theWinWaitActive
is unnecessary. – Charlie Armstrong