GetControlText Loop Termination failure

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

GetControlText Loop Termination failure

Post by JRL » Mon Jul 09, 2007 2:54 pm

Window text gathering experts (you know who you are), what am I doing wrong? From help for GetControlText> "if the class and instance was not found ##NOSUCHOBJECT## is returned." My problem is that if I open notepad and type in a few words, then run the following script, no matter what number is set for "instance" the notepad text is returned. I would expect that when instance is equal to 2 since there is not a second Edit class, result would be set to ##NOSUCHOBJECT## and the script would finish.

What am I missing?
Thanks for any help,
Dick

Code: Select all

Let>text_k=0
Let>result=
Let>composite_text=
Label>Retrieve_Loop
  Add>text_k,1
  GetControlText>Notepad*,Edit,%text_k%,Result
  If>%result%=##NOSUCHOBJECT##,text_done
  If>%text_k%=10,text_done
  Concat>composite_text,Item_%text_k%=%TAB%%TAB%%result%%CRLF%
Goto>Retrieve_Loop
Label>text_done
  PutClipBoard>%composite_text%

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

Post by Marcus Tettmar » Mon Jul 09, 2007 3:26 pm

It is returning NOSUCHOBJECT when the class does not exist but not when a class with that name exists but the instance is out of range. Not sure if the docs are wrong or if it's a bug. Will check it out.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jul 09, 2007 3:36 pm

Thanks.

Would be nice if it could work when the instance is out of range so that it could be detected in a loop like this.

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