Jump to content

Recommended Posts

Posted

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

Posted

Thanks for your attention. Unfortunately, it always writes "PuTTY is not running" not matter if PuTTY is started or not and active or hidden.

Posted

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.

Posted (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 by ioa747

I know that I know nothing

Posted

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.

Posted

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

Posted

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.

Posted (edited)

is it installation or is it portable

HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\

Edited by ioa747

I know that I know nothing

Posted

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

; 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

Posted

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?

Posted (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 by RSX

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...