Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to retrieve the contents of the Putty buffer from an AutoHotKey script? For many applications, WinGetText works, but it doesn't seem to for Putty. Also, the AHK Windows Spy doesn't display any text from the buffer, so I suspect that Putty simply uses a different method of storage/display for it's buffer.

I'm wondering if either you can enable a setting in Putty such that it will expose the contents of it's buffer in a Window-standard way that AHK could then pick up as the Visible Window Text.

Alternatively, I suppose there may be some feature of AHK that I'm not aware of that can get that text, but that seems less likely.

share|improve this question
1  
What are you trying to do overall? –  bobmagoo Aug 21 '12 at 0:12
    
Attachmate Reflections macros can be set up to wait until it sees certain text in the screen before it does a "Send". So if I want to have AHK automatically enter my username at a prompt, I can have the AHK script wait until the "Username:" prompt displays (for, say, a db login). I'm currently using AHK "Send", in combination with sleep,100 to handle the case where a database login prompt is slow to load (I have a db login script set to run from .profile at login). –  Cooper Aug 24 '12 at 20:51
    
I mean, overall, what are you trying to accomplish? Automatically connect to a database? Send something? –  bobmagoo Aug 25 '12 at 13:05
    
Yes - I want to automatically connect (and login) to a database. This involves navigating a series of text menus as well. –  Cooper Sep 6 '12 at 15:37
    
What database are you connecting to? From what? Surely there's an easier way to connect to a database than screen scraping. –  bobmagoo Sep 6 '12 at 16:11

1 Answer 1

I've done this sort of process before using the ImageSearch command: take a screenshot of an empty login prompt, and use ImageSearch to determine if the prompt has been reached. I've found this to be relatively reliable (though by no means perfect) - it may work for you!

For a more reliable system you'd probably need to write a script which does the ssh interaction for you, for example python with pexpect, which I have used successfully. Instructions on how to do that are outside the scope of this question, but depending on what scripting languages you are familiar (other than AutoHotKey) I'm sure there would be an option. I've no experience doing this kind of thing in perl, but it may be possible.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.