waardd Posted December 22, 2011 Share Posted December 22, 2011 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 comment Share on other sites More sharing options...
jaberwacky Posted December 22, 2011 Share Posted December 22, 2011 ProcessExists("process") Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 22, 2011 Share Posted December 22, 2011 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 comment Share on other sites More sharing options...
waardd Posted December 22, 2011 Author Share Posted December 22, 2011 @ 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"likeHotKeySet("{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 EndFuncBut the problem is that the putty screen is always a different title so i cant determine if the window is active Link to comment Share on other sites More sharing options...
waardd Posted December 22, 2011 Author Share Posted December 22, 2011 GO IT!!! Func _yes() ; Afvangen sh F2 en yes sturen $state = WinGetState("[CLASS:PuTTY]", "") If BitAnd($state, 8) Then Send("ls -ltr{ENTER}") EndIf EndFunc ; ==> _yes() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now