Jump to content

AutoIt not recognizing text within a PuTTY window.

Recommended Posts

I want to use AutoIt under Windows 10 to automate a PuTTY session. However, AutoIt is not recognizing any text inside of the PuTTY window.

This is what I have done ...

#include <Constants.au3>

;; The following creates new window to a PuTTY ssh session on
;; a different machine and waits for this window to become
;; active. The title of the window is "aa" ...
Run("putty.exe -load aa")
$w = WinWaitActive("aa")

;; The following properly pops up after the ssh window is fully open and active ...
MsgBox($MB_OK, "Status", "ssh window open")

;; This properly waits 5 seconds. Text is showing in the ssh window ...

$text = WinGetText("aa")

;; But this just pops up an empty message box with the title "Text" ...
MsgBox($MB_OK, "Text", $text)

I also tried WinGetText($w), and I got the same results.

I want to capture the PuTTY window text. What am I doing incorrectly?

Thank you very much in advance.

Link to comment
Share on other sites

PS: I have seen other posts here about controlling PuTTY, but they don't address this particular issue because ...

(1) ... they are invoking PuTTY via a "cmd" window. This will not work for me, because I need to use a fully-fledged PuTTY-created window which is managing an xterm-based terminal session.

(2) ... I could not find any examples where the text from a PuTTY terminal window is being read and examined. I only see cases where "Send" is used to send text to the PuTTY terminal window without first checking what text already appears in that PuTTY terminal window.


Link to comment
Share on other sites

I have nothing I can use for testing right now, but I can say in the past I used PLINK for my Putty automation.

If you use the AutoIT window info tool and you do not see any text listed, then you will not get anything from WinGetText()

I want to say you can have Putty pretty much log everything to a log file as its running, and then you can read that file as a workaround.

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

  • Recently Browsing   0 members

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