Dave in PNG Posted July 28, 2006 Share Posted July 28, 2006 WinGetText returns no error and just a blank string. The "Active Window Info" program shows the text I am looking for under "Visible Window Text". Even tried WinDetectHiddenText with the same result. Not what? Are there are any other options? Thanks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 29, 2006 Moderators Share Posted July 29, 2006 First Option: Show the Code you used In Addition to the First Option, post quote of the entire AutoInfo Tool Information. 2nd Option: No there's nothing else you can do if the first option and add on isn't done. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Dave in PNG Posted July 29, 2006 Author Share Posted July 29, 2006 Sorry, I considered the code to trivel to post. :"> Dim Const $TitleModem = "UU+m1 +SCS Pactor IIex" $Text = WinGetText($TitleModem, "") If @error Then MsgBox(4096,"Error", "Error on WinGetText") Endif if $Text = 1 Then MsgBox(0,"Title", "Couldn't find the window") Else $Text2 = StringFormat("[%s]", $Text); MsgBox(0,"Title", $Text2) Endif Active Window Info: >>>>>>>>>>>> Window Details <<<<<<<<<<<<< Title: UU+m1 +SCS Pactor IIex Class: TfCico Size: X: 18 Y: 596 W: 633 H: 308 >>>>>>>>>>> Mouse Details <<<<<<<<<<< Window: X: 455 Y: 150 Cursor ID: 2 >>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<< RGB: Hex: 0xFFFFFF Dec: 16777215 >>>>>>>>>>> Control Under Mouse <<<<<<<<<<< Size: X: 0 Y: 20 W: 625 H: 245 Control ID: 1507634 ClassNameNN: TListBox1 Text: >>>>>>>>>>> Status Bar Text <<<<<<<<<<< >>>>>>>>>>> Visible Window Text <<<<<<<<<<< 10:40:18 >>>>>>>>>>> Hidden Window Text <<<<<<<<<<< All I get back from the MsgBox call is "[]". Thanks. Link to comment Share on other sites More sharing options...
Helge Posted July 29, 2006 Share Posted July 29, 2006 Note: AutoIt only works with standard Microsoft controls - some applications write theirown custom controls which may look like a standard MS control but may resist automation.Experiment!If I'm not way off, TListBox is a Delphi-control, which I guess means that it will not work Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 29, 2006 Moderators Share Posted July 29, 2006 (edited) It looks like from the copy and paste that your missing a space before the title... try this and tell me what you get:$OptWTMM = Opt('WinTitleMatchMode', 4) Dim $TitleModem = WinGetTitle("classname= TfCico") $Text = WinGetText($TitleModem) Opt('WinTitleMatchMode', $OptWTMM) MsgBox(64, 'Info:', $Text) Edit: Your StringFormat() isn't correct either... With my example above you could probably get away with Opt('WinTitleMatchMode', 2) at the top of your script that you did (and fix the StringFormat) and it would probably work as well. @Helge... If AutoInfo is reading it, he shouldn't have a problem should he? (Serious question I don't know the answer to) Edited July 29, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Dave in PNG Posted July 29, 2006 Author Share Posted July 29, 2006 Using "Opt('WinTitleMatchMode', 4)" gets me "1" and "Opt('WinTitleMatchMode', 2)" gets me a blank. In my original code I was finding the correct window as I was not getting an error on WinGetText. Also if I purposefully munged the window title, I would an error. In addition "WinExists($TitleModem)" correctly fnds the window. So I'm pretty sure it's finding the right window. I do believe this is a Delphi app. If that is my problem, am I sunk as far as looking at Window contents? So why does the "Active Window Info" program see the text and WinGetText not see the text? I'd be happy to see I made a mistake. Thanks. Link to comment Share on other sites More sharing options...
Helge Posted July 29, 2006 Share Posted July 29, 2006 (edited) @Helge... If AutoInfo is reading it, he shouldn't have a problem should he? (Serious question I don't know the answer to)Sure, but isn't the text saying...nada ? Like in nothing. It could be my eyes,but I just changed my lenses, so I doubt it. Probalby just my brain again.Edit : time to go to bed I guess... 4AM. Edited July 29, 2006 by Helge Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 29, 2006 Moderators Share Posted July 29, 2006 (edited) Sure, but isn't the text saying...nada ? Like in nothing. It could be my eyes, but I just changed my lenses, so I doubt it. Probalby just my brain again.He's not getting the Control Text, he's going for the Visible Window Text:>>>>>>>>>>> Visible Window Text <<<<<<<<<<< 10:40:18 Edit: Dave is this a Child Window? Opt('WinSearchChildren', 1) Opt('WinTitleMatchMode', 2) Opt('WinDetectHiddenText', 1) Dim $TitleModem = "UU+m1 +SCS Pactor IIex" $Text = WinGetText($TitleModem, "") If Not $Text Then MsgBox(4096,"Error", "Error on WinGetText") Else MsgBox(0,"Text", $Text) EndIf Edit2: The statements were a tad messed up too. See if the above works. Edited July 29, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Dave in PNG Posted July 29, 2006 Author Share Posted July 29, 2006 (edited) BTW: I'm using AutoIt3 3.1.1 It's a spawned window from another app, yes.SmOke_N, concerning the code you just posted, my documentation says WinGetText:Returns a string containing the window text read. Returns numeric 1 if no title match.Your code gives me "Error on WinGetText".However if I check $Text, it is set to blank and @error is NOT set.So is WinGetText returning an error or not?Thanks. Edited July 29, 2006 by Dave in PNG Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 29, 2006 Moderators Share Posted July 29, 2006 (edited) BTW: I'm using AutoIt3 3.1.1 It's a spawned window from another app, yes. SmOke_N, concerning the code you just posted, my documentation says WinGetText: Your code gives me "Error on WinGetText". However if I check $Text, it is set to blank and @error is NOT set. So is WinGetText returning an error or not? Thanks.It doesn't return an Error there it returns a boolean... I had them backwards sorry, I was typing in the forum window. Just remove the Not. Here I just made this... It will check the window titles by using the .exe name... I used Notepad.exe as the example here:#cs ;~ Return values ;~ [N][1] = 'Title of Window' ;~ [N][2] = 'Handle of Window' ;~ [N][3] = 'Text of Window' #ce $aWinArray = _WinGetTextByPID('notpad.exe') If IsArray($aWinArray) Then For $i = 1 To UBound($aWinArray, 1) - 1 MsgBox(64, 'Info:', 'The title of window ' & $i & ' is: ' & $aWinArray[$i][1] & @CR & @CR & _ 'The handle of window ' & $i & ' is: ' & $aWinArray[$i][2] & @CR & @CR & _ 'The text of window ' & $i & ' is: ' & $aWinArray[$i][3]) Next EndIf Func _WinGetTextByPID($sExe) $OptWSC = Opt('WinSearchChildren', 1) $OptWDHT = Opt('WinDetectHiddenText', 1) Local $aStoreHwndAndText[2][4], $nCount = 1 Local $iPID = ProcessExists($sExe) If $iPID = 0 Then Return SetError(1, 0, 0) Local $aWinList = WinList() For $iCount = 1 To $aWinList[0][0] If WinGetProcess($aWinList[$iCount][1]) = $iPID And _ $aWinList[$iCount][0] <> '' Then $nCount += 1 ReDim $aStoreHwndAndText[$nCount][4] $aStoreHwndAndText[$nCount - 1][1] = $aWinList[$iCount][0] $aStoreHwndAndText[$nCount - 1][2] = $aWinList[$iCount][1] $aStoreHwndAndText[$nCount - 1][3] = WinGetText($aWinList[$iCount][1]) EndIf Next If $nCount = 1 Then Return SetError(2, 0, 0) Return $aStoreHwndAndText EndFuncIt returns a 2 dimensional array, just look at the example of calling it, I'm sure you'll understand how to get what you want from it. ****Edit:**** I'm sorry, this requires Beta... I just noticed you were only using the released version. http://www.autoitscript.com/forum/index.php?showtopic=23823 ****Edit2:**** There was a logic issue in the former code that threw an error, the above should work fine. Edited July 29, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Dave in PNG Posted July 29, 2006 Author Share Posted July 29, 2006 You all have been so helpful, but most of the answers I have gotten seem to focus in on the assumption that I'm not finding the correct window. In removing the "Not" from SmOke_N's code, I get a blank string, like I did with my original code.Just to prove that I am locating the correct window, I tried this code:Dim $TitleModem = "UU+m1 +SCS Pactor IIex" WinSetState($TitleModem, "", @SW_HIDE) Sleep(2000) WinSetState($TitleModem, "", @SW_SHOW)and I was able to hide and show the correct window.So I really don't think locating the window is the problem.So at the possibiity of offending someone, I'm going to repeat my question again:So why does the "Active Window Info" program see the text and WinGetText not see the text?Thank again. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 29, 2006 Moderators Share Posted July 29, 2006 So I really don't think locating the window is the problem.So at the possibiity of offending someone, I'm going to repeat my question again:So why does the "Active Window Info" program see the text and WinGetText not see the text?Thank again.It was a last ditch effort to help you man. The attempt wasn't that you weren't getting the "right" window, but maybe it was a Child and the code I gave you would find ALL the windows for that .exe and return ALL the info for ALL the windows that had a title for that .exe.I guess your answer was in thread #4 then. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Dave in PNG Posted July 29, 2006 Author Share Posted July 29, 2006 I apprecaite your hard work at finding out what is wrong. You're a great bunch. I compiled the code above using the beta release and it found only one window and a blank text string. So the puzzle continues. I found a really hack-eyed solution for my specific problem, but I'd still like to know why the "Window Info" program can see the text and a script can't. Being able to read the text would really help. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now