'GetWindowTextEx' doesnot fetch full contents everytime

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
jiby
Junior Coder
Posts: 30
Joined: Fri Feb 26, 2010 12:26 pm

'GetWindowTextEx' doesnot fetch full contents everytime

Post by jiby » Tue Jun 22, 2010 12:05 pm

hi,

I am current working on Windows XP on 32-bit.


I am trying to fetch the contents displayed in "control panel" window using

GetWindowTextEx>Control Panel,str

But, when I execute the script, sometimes all the contents is not getting stored in 'str'. Some text gets missed for few runs. Please let me know, if there is any way to set the buffer size to str and get all the contents of 'control panel' consistently everytime.

Thanks in advance.
jiby.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Launch Control Panel Application From The Command Line

Post by adroege » Tue Jun 22, 2010 12:45 pm

If you want to actually launch a control panel applet, there is a better way:

How To Launch Control Panel Application From The Command Line

http://samanathon.com/how-to-launch-con ... mand-line/

jiby
Junior Coder
Posts: 30
Joined: Fri Feb 26, 2010 12:26 pm

Post by jiby » Wed Jun 23, 2010 6:55 am

Thanks adroege,

But, my problem is that after launching the control panel, I am trying to get the text displayed as mentioned in my post.

--jiby

bnc1
Pro Scripter
Posts: 127
Joined: Sun Jul 31, 2005 5:10 pm

Re: 'GetWindowTextEx' doesnot fetch full contents everytime

Post by bnc1 » Wed Jun 23, 2010 10:36 am

jiby wrote:hi,

I am current working on Windows XP on 32-bit.


I am trying to fetch the contents displayed in "control panel" window using

GetWindowTextEx>Control Panel,str

But, when I execute the script, sometimes all the contents is not getting stored in 'str'. Some text gets missed for few runs. Please let me know, if there is any way to set the buffer size to str and get all the contents of 'control panel' consistently everytime.

Thanks in advance.
jiby.

I have similar experiences with the GetWindowTextEx command with Windows 7. Sometimes some of the text is simply missing. Use of the GetTextReset command doesnt help. I haven't tried your script with the control panel but your problem appears to be the same as I have seen on numerous occasions. It is my understanding that the text dll's (GetWordNT and ICall) come from another vendor. The version (3.3.1.136 ) that comes with MS v12 is the same as was in MS v11. Maybe it's time to explore newer versions ?? :D

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jun 23, 2010 11:08 am

There is no new version yet. We're waiting on new ones.

However, I don't think a new version will necessarily fix this problem. I think what is happening is that at the precise time the text capture functions are called the application that performs the text out processing is in a kind of idle state, or not at that moment outputting text. Imagine the text out functions as if they were being broadcast like radio. These functions are intercepted. We don't actually read from the screen itself - that isn't possible without using OCR. Instead we intercept the function calls. We need to intercept them when they are actually called. If you imagine it is like intercepting a radio signal then if we were unlucky enough to listen at a quiet moment we'd hear nothing.

Therefore what I do is use a loop. If I'm sure I will get something at some point then I will call GetWindowTextEx in a loop until something is returned.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Niroj@Work
Pro Scripter
Posts: 63
Joined: Thu Dec 10, 2009 8:13 am

I use this:

Post by Niroj@Work » Tue Jun 29, 2010 11:31 am

Code: Select all

/*TO GET THE TEXT PROPERLY FROM THE SCREEN HAVING
HAVING THE A KEY TEXT
NOTE: THE KEY TEXT MUST BE PRESENT ELSE IT WILL HANG...
*/

SRT>GET_PROPER_TEXT

Let>isPoP_proper=0
Repeat>isPoP_proper
  GetTextReset
  SetFocus>GET_PROPER_TEXT_Var_1
  WaitReady>0
  GetWindowTextEx>GET_PROPER_TEXT_Var_1,str_proper
  RegEx>GET_PROPER_TEXT_Var_2,str_proper,0,,isPoP_proper,0
Until>isPoP_proper<>0

END>GET_PROPER_TEXT

//GET_PROPER_TEXT FINISHED


//Syntax: GoSub>GET_PROPER_TEXT,terminal_name,unique key text
GoSub>GET_PROPER_TEXT,Control Panel,Switch\s+to\s+(Category|Classic)\s+View
MDL>str_proper

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts