Jump to content

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?

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)
Sleep(2500)
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

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"

like

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

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

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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...