Jump to content
Sign in to follow this  

Hotkey only active when putty active

Recommended Posts


I have a script that replaces function keys for commands in putty.

But... these keys also work when putty is not active.

I know you can use WinActive() to check if a certain window is active but the putty window always has a different title.

How can i get it to work that my keys only get replaced when a putty session is active?

Share this post

Link to post
Share on other sites

Go for the classes.

Something like this

Func _puttyAnmeldung()
Run('"' & @ComSpec & '" /c putty -ssh', '', @SW_HIDE)
WinWaitActive('[CLASS:PuTTYConfigBox]', '', 5)
ControlSend('[CLASS:PuTTYConfigBox]', '', 1008, "+{TAB}" & "Ses" & "{TAB}")
ControlSetText('[CLASS:PuTTYConfigBox]', '', 1044, $sUsername & "@" & $SLoginServer)
ControlClick('[CLASS:PuTTYConfigBox]', '', 1009, 'left', 1)
WinWaitActive('[CLASS:PuTTY]', '', 5)
If ControlSend('[CLASS:PuTTY]', '', '', $sPassword & '{ENTER}') Then _log("Password sent")
EndFunc   ;==>_puttyAnmeldung

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

@ LaCastiglione i see what you mean but process is always running. But i want the key-replace to only be effective if putty is active.

@ Xenobiologist I see what you are doing. Taking putty to tyhe foreground and then execute command. But thats not what im searching for but i can understand teh confusion.

What i would like...

If putty is not active send normal F2 else if putty is active send "ls -ltr"


HotKeySet("{F2}", "_F2")
;;;; Body of program would go here ;;;;
While 1
    ; My main program

Func _F2()
If WinActive("PuTTY") Then
  Send("ls -ltr{ENTER}")

But the problem is that the putty screen is always a different title so i cant determine if the window is active

Share this post

Link to post
Share on other sites

GO IT!!! :)

Func _yes() ; Afvangen sh F2 en yes sturen

$state = WinGetState("[CLASS:PuTTY]", "")

If BitAnd($state, 8) Then

Send("ls -ltr{ENTER}")


EndFunc ; ==> _yes()

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.