RSX Posted November 21 Posted November 21 Hi, started using AutoIt yesterday to change font settings of existing session with PuTTY and was able to figure out some basics: #include <GuiMenu.au3> #include <WinAPIProc.au3> HotKeySet("#!p", CustomizePutty) ;Win+Alt+p While 1 Sleep(10) WEnd Func CustomizePutty() $hWnd = WinGetHandle("[ACTIVE]", "") $iPID = WinGetProcess($hWnd) $exe = _WinAPI_GetProcessName($iPID) If $exe = "putty.exe" Then WinSetState($hWnd, "", @SW_MAXIMIZE) $hMenu = _GUICtrlMenu_GetSystemMenu($hWnd) msgbox(0, "t", $hMenu) EndIf EndFunc I've read almost hundred of examples or posts but I'm unable to find out how to proceed. I've no glue how to code the next steps: open systemmenu select Change settings... select Window/Appearance etc. Could anybody please light some shed e.g. pointing to suitable commands or even known examples? TIA Roland
ioa747 Posted November 21 Posted November 21 test if this works so we can move on HotKeySet("#!p", "CustomizePutty") ;Win+Alt+p While 1 Sleep(50) WEnd Func CustomizePutty() If WinExists("PuTTY") Then Local $hPuttyWnd = WinGetHandle("PuTTY") WinActivate($hPuttyWnd) Else ConsoleWrite("PuTTY is not running" & @CRLF) EndIf EndFunc I know that I know nothing
RSX Posted November 21 Author Posted November 21 Thanks for your attention. Unfortunately, it always writes "PuTTY is not running" not matter if PuTTY is started or not and active or hidden.
ioa747 Posted November 21 Posted November 21 what information does Au3Info.exe give you about the PuTTY window I know that I know nothing
RSX Posted November 21 Author Posted November 21 Hmm, I was signed out so my answer vanished. I'd assume you want to know the Title and this changes every time and session. Class instead is always PuTTY. But this approach sounds to me not best option as WinActivate uses always the last found instance if I have multiple sessions open at the same time. Hence, I'd prefer to act on the currently active window and only if it's PuTTY.
ioa747 Posted November 21 Posted November 21 (edited) you mean the PuTTY Configuration window Edited November 21 by ioa747 I know that I know nothing
ioa747 Posted November 21 Posted November 21 (edited) is there any shortcut so that the configuration window comes in front? or this will only happen when the configuration window is active? Edited November 21 by ioa747 I know that I know nothing
RSX Posted November 21 Author Posted November 21 PuTTY can be configured to open the systemmenu with Alt+Space, but is is disabled and I cannot enable (since it always gets overwritten by main application). The same happens to font settings and that's why I try to solve this with AutoIt.
ioa747 Posted November 21 Posted November 21 Alt+Space it's something different, and it works on almost all windows. The issue is when you press the shortcut alt windows p for the window to come forward it must be there, and from what it seems, if you are running others season, this is not available, it is not even hidden I know that I know nothing
RSX Posted November 21 Author Posted November 21 There is no existing window. Usually I use the mouse to click on the systemmenu (which normally also works with Alt+Space), then I chose "Change settings..." from that menu and this opens a new window where all the settings can be changed.
ioa747 Posted November 21 Posted November 21 in configuration window go to window|Behaviour and check System menu appears on ALT alone I know that I know nothing
ioa747 Posted November 21 Posted November 21 (edited) is it installation or is it portable HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\ Edited November 21 by ioa747 I know that I know nothing
ioa747 Posted November 21 Posted November 21 since we didn't get an edge to begin with, I proceeded to the solution with the mouse for example how you can interact with the controls expandcollapse popup; https://www.autoitscript.com/forum/topic/212486-how-to-change-setting-for-putty/?do=findComment&comment=1538741 #include <GuiTreeView.au3> HotKeySet("#!p", "CustomizePutty") ;Win+Alt+p While 1 Sleep(50) WEnd Func CustomizePutty() If WinActive("[CLASS:PuTTY]") Then Local $hWnd = WinGetHandle("[ACTIVE]") Local $aWPos = WinGetPos($hWnd) ; position and size of PuTTY window. Local $aMPos = MouseGetPos() ; backup mouse position ; Perform a mouse click operation MouseClick("right", $aWPos[0] + 50, $aWPos[1] + 10, 1, 1) ; and send g to call chan&ge setting in contex menu ControlSend("[CLASS:#32768]", "", "", "g") MouseMove($aMPos[0], $aMPos[1] ,1) ; restore mouse position ; Get handle of Reconfiguration window Local $hPWnd = WinWaitActive("PuTTY Reconfiguration", "", 5) ConsoleWrite("$hPWnd=" & $hPWnd & @CRLF) ; Get handle of SysTreeView32 menu Local $hTVctrl = ControlGetHandle($hPWnd, "", "SysTreeView321") ConsoleWrite("$hTVctrl=" & $hTVctrl & @CRLF) ; Sets focus to SysTreeView32 menu ControlFocus($hPWnd, "", $hTVctrl) ; Returns the the current selection $cur = ControlTreeView($hPWnd, "", $hTVctrl, "GetSelected") ConsoleWrite("current selection=" & $cur & @CRLF) ;select the "Window|Behaviour" item ControlTreeView($hPWnd, "", $hTVctrl, "Select", "Window|Behaviour") $cur = ControlTreeView($hPWnd, "", $hTVctrl, "GetSelected") ConsoleWrite("current selection=" & $cur & @CRLF) ; for this control you will need it ; https://www.autoitscript.com/forum/files/file/478-control-viewer-mod/ If $cur = "Window|Behaviour" Then ControlSetText($hPWnd, "", "Edit1", "My new connecton") ControlSend($hPWnd, "", "Button8", "{SPACE}") Sleep(5000) ; give some time to see what ... ; click &Apply ControlClick ($hPWnd, "", "Button1") EndIf Else ConsoleWrite("is not PuTTY" & @CRLF) EndIf EndFunc ;==>CustomizePutty informative: although I don't know how you use it I was more comfortable with WinSCP I know that I know nothing
RSX Posted November 22 Author Posted November 22 Oh, wow, that's awesome. This helps a lot. Thank you! Unfortunately, ...GetSelected... returns nothing and after ...Select... nothing changed. Any idea what's wrong here?
ioa747 Posted November 22 Posted November 22 put this at the top of the script and try again #AutoIt3Wrapper_UseX64=y I know that I know nothing
RSX Posted November 22 Author Posted November 22 ControlTreeView($hPWnd, "", $hTVctrl, "Select", "#2|#1") Using this notation works as expected, no matter if #AutoIt3Wrapper_UseX64=y is in the script.
RSX Posted November 25 Author Posted November 25 (edited) Using this workaround brings me to the next challenge: How can I select the button labeled as Change...? With AutoIt's Finder Tool I get the info there is a control named Button14 but highlights (what I call) a frame (in this case named Font settings). But I don't see a control for the button labeled Change.... How can I enumerate the controls inside Button14? Or do I have to use MouseClick for this step? Edited November 25 by RSX
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