AutoHotkey PuTTY restart session shortcut

A handy AutoHotkey snippet to restart a PuTTY session after it gets disconnected, press Ctrl + R in the session to restart.

More ids for putty shortcuts can be found here.

if WinActive("ahk_class PuTTY") {
^r:: ; ^r = Ctrl + R
TrayTip, PuTTY, Restarting Session...
WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
WinGetClass class, ahk_id %hwnd%
;0x112 = SYS_COMMAND, 0x40 = IDM_RESTART
PostMessage, 0x112, 0x40,,, ahk_id %hwnd%
Return
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s