Jump to content

Write third party output to text


Recommended Posts

I have a third party (Windows 32 bit) application that writes textual information to a window.  I would like to use Autoit to write that text to a file in real time (or near real time), if possible.  I have played around with the AutoIt v3 Window Info tool to try and retrieve control info on the third party window where the text appears.  But this is my first foray into this realm and I'm having trouble figuring out the next step.  The "Visible Text" tab for the third party window is empty--I would have hoped this would contain the text information I want to copy.

A little additional info, in the third party window containing the desired text, ctrl-a will not select all text in the window.  I can however, click and drag to select all text, and subsequently copy and paste into a text file.  However I would like to avoid a click and drag in my situation.  Furthermore, the third party window will only allow me to select discrete lines of text (i.e. I cannot select a subset of text from any line--the entire line is selected when I click on it. Any ideas?  Let me know if you need more details.

Thanks in advance.

Link to comment
Share on other sites

Hi,

The first thing I'd do is check the hidden text tab on the window info tool. If your text is there, there is an autoitsetoption command you can use, Opt(WinDetectHiddenText,1) then use WinGetText to get the hidden text.

If that doesn't work, you may be looking at one of those custom controls, and it's more iffy. In case it's made of several controls, I'd look into possible child classes of the control you are seeing in the window info tool. You could write a little tool to list those children using WinGetClassList(), and loop through all those children, get their text properties and display them. You  just might find this way the text you're looking for. If you get there, you can then do what you want with the text.

Finally there is _SendMessage, you could send a LB_SETSEL (hex 185) if it's really a listbox (looks like it could be from your description), and you could also try EM_SETSEL (hex B1) to select all without a click. If that works, you can copy the selected text, and use it elsewhere.

Good luck.

Link to comment
Share on other sites

Thanks a lot.  I forgot to mention that the hidden text tab was also empty.  But the other two ideas sound promising.  I may have to wait for a week or so to try them, as I'm out of the office.  But I'll let you know my results.

Link to comment
Share on other sites

  • 2 weeks later...

OK I've had a chance to try your suggestions.

Hi,

The first thing I'd do is check the hidden text tab on the window info tool. If your text is there, there is an autoitsetoption command you can use, Opt(WinDetectHiddenText,1) then use WinGetText to get the hidden text.

I forgot to mention that the hidden text tab is also empty.

If that doesn't work, you may be looking at one of those custom controls, and it's more iffy. In case it's made of several controls, I'd look into possible child classes of the control you are seeing in the window info tool. You could write a little tool to list those children using WinGetClassList(), and loop through all those children, get their text properties and display them. You  just might find this way the text you're looking for. If you get there, you can then do what you want with the text.

I tried this.  WinGetClassList() returned a list of child classes (20 total, a handful of duplicates).  On each of those I ran ControlGetText.  However each returned a blank string and @error=1, indicating I'm doing something incorrectly.  I'm reasonably sure I'm using the correct parameters for the first 2: I obtained "title" and "text" using AutoItWinGetTitle() and WinGetText() respectively.  For the third parameter, controlID, I used the text output from WinGetClassList().  Thoughts?

Finally there is _SendMessage, you could send a LB_SETSEL (hex 185) if it's really a listbox (looks like it could be from your description), and you could also try EM_SETSEL (hex B1) to select all without a click. If that works, you can copy the selected text, and use it elsewhere.

This sounds promising, however I would need a nudge in the right direction to even get started on carrying this out.  I looked at the _SendMessage() syntax, but couldn't figure out how to send LB_SETSEL or EM_SETSEL.  I should say that the window in-question is similar to a list box, but slightly different than a classic list box.  Clicking on a line in this window will select the entire line, but clicking again will not deselect.  Once I've selected a line, and I click on another line, the first line is deselected and the new line is selected.  I can however click on a line and drag, selecting all lines in between.  Also, this window is somewhat of a vertical ticker, with new lines of text appearing at the bottom over time, and old lines disappearing at the top.  

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