Jump to content

How to change setting for PuTTY?


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...