Problem with GetTextInRect

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
kevinkalexander
Newbie
Posts: 5
Joined: Mon Dec 16, 2013 5:56 pm
Location: Richardson, TX, USA
Contact:

Problem with GetTextInRect

Post by kevinkalexander » Wed Aug 31, 2016 12:37 pm

I've been struggling to get GetTextInRect to return anything in the result. I've played around with all sorts of rectangles on the screen in various places with various types of text, but the result string is ALWAYS empty. I'm using GetTextInit just before the call, like so:
Label>WaitForLogin
FindImagePos>%BMP_DIR%\login.bmp,SCREEN,0.7,3,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
GetTextInit
GetTextInRect>XArr_0, YArr_0+3,XArr_0+200,YArr_0+23,strResult
**BREAKPOINT**
If>strResult<>
UserName=strResult
Else
Goto WaitForLogin
EndIf
Else
Goto>WaitForLogin
EndIf

I'm sure my rectangle is the appropriate size. It encompasses a TextBox input control for the Username of a login screen. I'm trying to trap the name of the user logging in to an app. I've swapped out the given rectangle for exact coordinates all of the screen just trying to capture something. I've tried the "Username" label above the TextBox input. I've tried MS's Debug menu option, I've tried text in the MS Editor. Nothing seems to work. I'd like to get it to at least return something so I can prove that it would work.

BTW, it's version 14.2.03

Any help is appreciated.
-Kevin
Kevin K Alexander

Jerryth31
Newbie
Posts: 19
Joined: Wed Jun 18, 2008 6:03 pm

Re: Problem with GetTextInRect

Post by Jerryth31 » Wed Aug 31, 2016 1:46 pm

What version of Windows?

kevinkalexander
Newbie
Posts: 5
Joined: Mon Dec 16, 2013 5:56 pm
Location: Richardson, TX, USA
Contact:

Re: Problem with GetTextInRect

Post by kevinkalexander » Wed Aug 31, 2016 1:49 pm

Win7 64bit
Kevin K Alexander

kevinkalexander
Newbie
Posts: 5
Joined: Mon Dec 16, 2013 5:56 pm
Location: Richardson, TX, USA
Contact:

Re: Problem with GetTextInRect

Post by kevinkalexander » Wed Aug 31, 2016 2:29 pm

I've done some experimentation. I finally got GetTextAtPoint to return the label to the TextBos of "Username". I found that I had to use hard coded coordinates rather than calculated coordinates like I was trying in the sample code. Once I moved the point down into the TextBox, I still got nothing. So, that tells me that I cannot read text out of this TextBos control (?).

I've proven GetTextAtPoint works, and it works on this screen but it just doesn't work in the TextBox. I still can't get GetTextInRect to return anything, but GetTextAtPoint would work if needed. I guess I'm just out of luck with this control.
Kevin K Alexander

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

Re: Problem with GetTextInRect

Post by JRL » Wed Aug 31, 2016 2:54 pm

GetTextInRect>XArr_0, YArr_0+3,XArr_0+200,YArr_0+23,strResult
Is incorrect syntax, you can't do math the way you are attempting to do it in each parameter, plus you have an extra space in front of YArr_0+3.
Try doing the math on separate lines creating new variables then using those variables as the GetTextInRect parameters.

For example:

Code: Select all

Let>ULx=XArr_0
Let>ULy=YArr_0+3
Let>LRx=XArr_0+200
Let>LRy=YArr_0+23

GetTextInRect>ULx,ULy,LRx,LRy,strResult

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

Re: Problem with GetTextInRect

Post by Marcus Tettmar » Wed Aug 31, 2016 3:27 pm

Or you can do it on one line like this:

GetTextInRect>XArr_0,{%YArr_0%+3},{%XArr_0%+200},{%YArr_0%+23},strResult
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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