I have a simple AutoHotkey script to deal with any Telnet/SSH session opened from Windows. It might help somebody:
SetTitleMatchMode 2 ; 2 - partially, 3 - exact match MyWinTitle=- PuTTY ; Describe the window for keep alive signals Timeout=180000 ; Call KeepAlive every 180 seconds (180000 ms) ttl := Timeout / 1000 ToolTip, Keepalives every '%ttl%' seconds for the last touched '%MyWinTitle%' window`nTo stop the keepalive press F12 SetTimer, RemoveToolTip, 3000 ; Shows the tooltip for 5 seconds return RemoveToolTip: SetTimer, RemoveToolTip, Off ; only once ToolTip Gosub, MyKeepAlive Return MyKeepAlive: WinGetActiveTitle, Title IfWinExist, %MyWinTitle% { WinActivate WinGet, mywin_id WinGetActiveTitle, mywin_title Send {!} MsgBox,,Info message, The window for keep-alives is '%mywin_title%',3 WinActivate, %Title% } else { MsgBox,,Exit message, Open the window first!,10 ExitApp } SetTimer, KeepAlive, %Timeout% Return KeepAlive: WinGetActiveTitle, Title WinGetTitle, current_title, ahk_id %mywin_id% If current_title = %mywin_title% { WinActivate, ahk_id %mywin_id% Send {!} WinActivate, %Title% } else { MsgBox,,Exit message, The window was closed!,10 ExitApp } Return Return F12::ExitApp ; Exit button