Sign in to follow this  
Followers 0
GlyphMaker

ControlGetText returning "" in a non-empty window

22 posts in this topic

I'm working within VB, because I have already created so much code to run my equipment and do other stuff. I have a question concerning the proper use (and my apparent misuse) of ControlGetText, via the DLL.

In the hours since I've begun working with AutoIt, I've been able to accomplish a lot. I'm impressed with this tool. I'm getting data on optical media in my lab much more easily than before I pressed AutoIt into service as an imported feature to my VB programs.

In this instance, I've already got a way to get a targeted, slave application to save data, which I can then parse in one of many usual fashions in VB. That's what I'm doing now, and it works just fine...though it seems kind of circuitous, even Rube Goldbergish,to have to save data I can see right on the screen, in order to go read it back.

:)

I would like to know if I can get around the need to save the data into a text file, since it's already visible on the screen before it is saved. It will clean-up and speed-up my process to just get it off the screen, which I understand is trivial for AutoIt.

Using the "Window Info" tool, I am able to isolate the box containing the text I want to parse. The report from the "Window Info" utility is as follows:

>>>> Window <<<<

Title: ADIPError - ADIP Error Check Program

Class: Afx:400000:b:10011:6:a9502f5

Position: 22, 25

Size: 982, 619

Style: 0x14CFC000

ExStyle: 0x00000100

Handle: 0x00220464

>>>> Control <<<<

Class: AfxWnd42s

Instance: 2

ClassnameNN: AfxWnd42s2

Advanced (Class): [CLASS:AfxWnd42s; INSTANCE:2]

ID: 1

Text:

Position: 2, 63

Size: 953, 482

ControlClick Coords: 851, 278

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x002704F6

>>>> Mouse <<<<

Position: 879, 416

Cursor ID: 2

Color: 0xFFFFFF

>>>> StatusBar <<<<

1: Ready

2: Oct,03,2009 05:58:31 PM

3:

4: NUM

5:

>>>> Visible Text <<<<

Ready

Start(&S)

>>>> Hidden Text <<<<

Unfortunately, my attempts to do a ControlGetText on the region of the screen containing the data I want have met with a "" being returned. So, I'm probably getting it wrong. The line from my VB code looks like this:

ReportText = cAutoIt.ControlGetText("ADIPError - ADIP Error Check Program", "", 1)

So, either this is wrong, or there's something else going on. Notably, the stuff reported under "Visible Text" in the "Window Info" tool is not what I see on the screen at all. There are several columns of data there (the stuff I'm currently having the application save to file for parsing). I'm kinda stumped.

So, how else might I go about getting the text off the screen? Is ControlGetText the right channel? Or must I do something else? Please know, I've been combing the helps and forums for quite a while, before posting my question. Your expertise is my hope, after the failure of my resourcefulness.

:)

By the way, that second argument in the ControlGetText call makes no sense to me. I mean, if I know the text I'm trying to get already, under what circumstances would I need to go "get" it in the first place? Curious.

Share this post


Link to post
Share on other sites



Try doing just ControlGetText("ADIPError - ADIP Error Check Program", "", "")

The second parameter of ControlGetText is so you can differentiate between windows with the same title, I think. It's not really needed, "" will tell it "Active window" basically.


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Try doing just ControlGetText("ADIPError - ADIP Error Check Program", "", "")

The second parameter of ControlGetText is so you can differentiate between windows with the same title, I think. It's not really needed, "" will tell it "Active window" basically.

Thanks, mistersquirrle.

I'll give that a try....

K...

Ran it in the VB debugger...

Checked what went into variable "ReportText..."

Nope.

No dice. It just gives me back the window title. Oh boy...

But I appreciate your reply.

Share this post


Link to post
Share on other sites

Yeah I tested that, and it kept giving me the window title... I don't know how you'd do it with your VB and stuff, but you could try this...

For $i = 1 To 999 ;just a loop to go through all the Controls, I dunno a better way then putting in a really big number...
    $Text = ControlGetText("ADIPError - ADIP Error Check Program", "", $i)
    If StringInStr($Text, "Start") Then ;Checks the string returned from ControlGetText for "Start"
        ;Do what you want here... ControlClick("ADIPError - ADIP Error Check Program", "", $i) would click the "Start" or at least the control it's in, assuming it's a button
        ExitLoop ;Important, otherwise it'll keep going through looking for "Start"
    EndIf
Next

I suggest getting SciTE and running that with the Error window up, see if it'll work. Also before the "If StringInStr" line, you could put Msgbox(64, "Returned...", $Text) to see what was getting returned


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Yeah I tested that, and it kept giving me the window title... I don't know how you'd do it with your VB and stuff, but you could try this...

For $i = 1 To 999 ;just a loop to go through all the Controls, I dunno a better way then putting in a really big number...
    $Text = ControlGetText("ADIPError - ADIP Error Check Program", "", $i)
    If StringInStr($Text, "Start") Then ;Checks the string returned from ControlGetText for "Start"
        ;Do what you want here... ControlClick("ADIPError - ADIP Error Check Program", "", $i) would click the "Start" or at least the control it's in, assuming it's a button
        ExitLoop ;Important, otherwise it'll keep going through looking for "Start"
    EndIf
Next

I suggest getting SciTE and running that with the Error window up, see if it'll work. Also before the "If StringInStr" line, you could put Msgbox(64, "Returned...", $Text) to see what was getting returned

K.

I'll take a look. I'm under the gun - been in the lab all night, all day the previous day, blabeddy, bla, waaah. So, it may take me a while to implement that idea. As I mentioned in the first post, to which you've kindly replied (not to be taken for granted here, I gather from some of the other exchanges I've read) I've got AutoIt doing the lion's share of what I need already. It's just this silly file-save thing I'm trying to get around. I'm being picky. The real task here is to develop a tool for the evaluation of optical media, not necessarily for me to become an AutoIt expert overnight.

You know, how awesome of someone to actually bother to fashion a code response to the inquiry of a perfect stranger! Kudos to you. It's not just the code that counts. Please go and enjoy your Saturday, and don't be bothered by my noob question any further. If I could, I would be home with the kiddos right now myself.

I'll figure something out. That's what "they" pay us for, right?

:)

Share this post


Link to post
Share on other sites

Heh, I guess so. I hope you can do what you want to, I haven't had much use to use ControlGetText, so I don't really know how it works. And I like writing in AutoIt, I think it's fun, and that was a tiny little script :)

Oh, also, when you have time, try looking at WinGetText... I think that that might also get you to where you want to be. Again, I don't know how much you can do with AutoIt being an imported feature, but

MsgBox(64, "Return...", WinGetText("ADIPError - ADIP Error Check Program"))

I didn't think of that before, but that should return all the text in the window... it won't help you to much if you want to click a button with certain text, but that previous one I posted should do that...


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Heh, I guess so. I hope you can do what you want to, I haven't had much use to use ControlGetText, so I don't really know how it works. And I like writing in AutoIt, I think it's fun, and that was a tiny little script :)

Oh, also, when you have time, try looking at WinGetText... I think that that might also get you to where you want to be. Again, I don't know how much you can do with AutoIt being an imported feature, but

MsgBox(64, "Return...", WinGetText("ADIPError - ADIP Error Check Program"))

I didn't think of that before, but that should return all the text in the window... it won't help you to much if you want to click a button with certain text, but that previous one I posted should do that...

I'm still poking at it. I can't get the content I'm after yet. Again, it seems to me that this should be trivial. It's a plain text box on a window having minimal functionality. That is, the slave app is really simple. I dunno. Maybe the text is somehow "hidden." Thank you for the ideas.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

EDIT: Try any of these:

ControlGetText('ADIPError - ADIP Error Check Program', '', "[CLASS:AfxWnd42s; INSTANCE:2]")
ControlGetText('ADIPError - ADIP Error Check Program', '', "[CLASSNN:AfxWnd42s2]")
ControlGetText('[CLASS:Afx:400000:b:10011:6:a9502f5]', '', "[CLASS:AfxWnd42s; INSTANCE:2]")
ControlGetText('[CLASS:Afx:400000:b:10011:6:a9502f5]', '', "[CLASSNN:AfxWnd42s2]")
Edited by danwilli

Share this post


Link to post
Share on other sites

Try:

ControlGetText( 'ADIPError - ADIP Error Check Program', '', "[CLASS:AfxWnd42s; INSTANCE:2]" )

or

ControlGetText( 'ADIPError - ADIP Error Check Program', '', "[CLASSNN:AfxWnd42s2]" )

Hmmm.. Let me see...

Both return the same thing. That is, instead of returning all of the ADIP information I need from my analyzer (clearly visible on the form) it gives me

"Ready Start(&S)"

Strange. Now I'm beginning to think there's something funny going on with the form I'm trying to sniff-out. It just looks like a plain-old text window, but there must be some evil within.

Thank you for a thoughtful reply.

Share this post


Link to post
Share on other sites

>>>> Visible Text <<<<

Ready

Start(&S)

Both return the same thing. That is, instead of returning all of the ADIP information I need from my analyzer (clearly visible on the form) it gives me

"Ready Start(&S)"

That is exactly what is SHOULD give you. If you do not see the text you are after in the Window Info tool you are using, then you are not looking at the correct control. What text are you after, maybe you could re-check the controls on the window with the Window Info tool to find a control that contains that text. Is the tool not finding a control with that text at all? Does WinGetText() get the text you are looking for?

Share this post


Link to post
Share on other sites

EDIT: Try any of these:

ControlGetText('ADIPError - ADIP Error Check Program', '', "[CLASS:AfxWnd42s; INSTANCE:2]")
ControlGetText('ADIPError - ADIP Error Check Program', '', "[CLASSNN:AfxWnd42s2]")
ControlGetText('[CLASS:Afx:400000:b:10011:6:a9502f5]', '', "[CLASS:AfxWnd42s; INSTANCE:2]")
ControlGetText('[CLASS:Afx:400000:b:10011:6:a9502f5]', '', "[CLASSNN:AfxWnd42s2]")

This one:

ReportText = cAutoIt.ControlGetText("[CLASS:Afx:400000:b:10011:6:a9502f5]", "", "[CLASS:AfxWnd42s; INSTANCE:2]")

Gets me "" for ReportText, which is declared as a string

as does:

ReportText = cAutoIt.ControlGetText("[CLASS:Afx:400000:b:10011:6:a9502f5]", "", "[CLASSNN:AfxWnd42s2]")

Curiouser and curiouser, but thank you. I noticed single and double quotes being used. Am I missing something?

Share this post


Link to post
Share on other sites

I noticed single and double quotes being used. Am I missing something?

Nope just me changing it up every now and then for some reason.... well, to be honest, there is no actual reason, they are treated the same, the way I have used them. haha

I asked some questions in a new post while you were writing your last post though that should help clear some things up hopefuly.

Share this post


Link to post
Share on other sites

I know this'll only provide a little more information for us, but could you upload a screenshot of this mystery text window?


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

That is exactly what is SHOULD give you. If you do not see the text you are after in the Window Info tool you are using, then you are not looking at the correct control. What text are you after, maybe you could re-check the controls on the window with the Window Info tool to find a control that contains that text. Is the tool not finding a control with that text at all? Does WinGetText() get the text you are looking for?

Very interesting comment. It is true that I do not see the body of the text (the data I am collecting) in the "Visible Text" portion of the Window Info tool, even when I take the inspection directly to the panel containing the text. Perhaps I've got some other pathology here. Goodness.

So, am I to understand that, without exception, I should see all of the text from the control of interest in the "Window Info" tool, when I take its focus there? I assumed that, since there is quite a lot of data on display, the tool does not attempt to show it all. But that wouldn't be a graceful way to handle the situation, either. Yes, it does seem that what I am looking at is not a straightforward text-bearing control. Another thing I've noticed - revolting really - is that it is not possible to select any of the text on display using the mouse. It's not behaving at all like a regular text box. Hmm... Now why would these guys go and do that?

:)

So sorry, I seem to have bothered others with a question that presumes that just because I'm looking at text, it is, in fact, text. What if it's stinking graphics? Aaargh. I need to re-evaluate this...

Thank you, kindly, for your attempts to make sense of this. The information you have is only as good as what I provide, and I seem to have been beguiled.

:)

Share this post


Link to post
Share on other sites

Yes, "Visible Text" will show all of the text that would be returned if using ControlGetText() on the control. In fact, the Window Info tool probably uses the ControlGetText() funtion to populate that field.

Share this post


Link to post
Share on other sites

I know this'll only provide a little more information for us, but could you upload a screenshot of this mystery text window?

It's a bunch of hex. Plain-Jane black letters on a white background. It's got the "physical format information" for a DVD on it, which is fairly esoteric stuff. Basically (not that any of you are terribly concerned, but it's sort of show-and-tell fodder) what I'm looking at is decoded information from a blank, recordable DVD. As few know, there is information encoded in the so-called "wobble groove" of the disc - the spiral groove "into" which the data are eventually recorded. What I am evaluating is essentially an error rate for that encoded information.

Gosh, guys, I'm sorry. Normally, I think more clearly than this. I should have suspected that there is something up with this deceptively-straight-forward looking window. I'm dubious as to whether this is a garden-variety text box. These bozos who make the software for the instrument seem not to have intended for people to select, copy and paste information into or out of it, and the strategy they have used is probably what is frustrating my attempt to snarf the data using AutoIt.

Oh, well. Besides, I don't even know how to paste an image of anything into this board. How lame am I for that?

:)

If you've got any ideas, great. If you don't, I can always stick to my save-file-and-parse approach. AutoIt is still kicking butt on that front, because it keeps my target users from having to interact with the program or change inputs on the oscilloscopes,etc. I'm cool with it.

Share this post


Link to post
Share on other sites

I've got an idea... You're going to hate it :) but I've got one. Assuming the text is all the same format and size and all (and mono spaced font, like courier new) you could write a script to do pixel searches, and have it feel out the text! :P like "If this = black then if this = black then if this = black then $letter1 = a" :) yay ideas


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Is this a freeware application that you could send or link me to?

Share this post


Link to post
Share on other sites

I've got an idea... You're going to hate it :) but I've got one. Assuming the text is all the same format and size and all (and mono spaced font, like courier new) you could write a script to do pixel searches, and have it feel out the text! :lol: like "If this = black then if this = black then if this = black then $letter1 = a" :P yay ideas

Oh, the horror! Yuck.

Now, look, I have been accused of masochism for the hours I keep at work, and for my many other days playing "Mr. Mom" to my quad infants, but you gotta draw the line somewhere. That would just be ugly. It's like you're talking about OCR on the screen contents. Sure, AutoIt has that too, right?

:)

Ok, I'm going to officially declare my question dead. I am going to finish this stinking VB code using the AutoIt methods already in play, run a few disc tests, go the heck home, get yelled at by my Ukrainian wife, sit on my couch, and get crawled on and have my crotch stomped by those crazy little rug-rats all fighting for lap space, hugs and attention.

:idea:

You guys have been great. Please have a good weekend.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Is this a freeware application that you could send or link me to?

Danwilli,

There are some freeware analyzer programs out there, in fact. Mine is not one of them. Its a program sold with a $300,000.00 lab instrument made in Japan. But still, if you're looking for analysis of the ADIP info on a disc, you can fairly easily come-up with it, I think.

Respects.

*Edit

Maybe have a look at this?

DVD Identifier

Edited by GlyphMaker

Share this post


Link to post
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
Sign in to follow this  
Followers 0