Hi All,
Can I get the relative X,Y position on a window where a specific Text is found?
Also, can I catch the text linewise on a window screen?
What Exactly I am doing:
----------------------------
1)Finding a specific TEXT1 on the screen
2)If the TEXT1 is FOUND
>Start reading TEXT line by line TILL another specific TEXT2 found below the TEXT1
>IF TEXT2 NOT found Press Down
If not possible with direct command can you please provide any indirect method to do this?..
Thanks..
Get X,Y pos where a specifix text appears
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 63
- Joined: Thu Dec 10, 2009 8:13 am
- Marcus Tettmar
- Site Admin
- Posts: 7391
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The only way to do this right now would be to loop through all pixels on the window, and get the text at that point. If you have a match you know the position. It would probably be quite slow though. E.g.:
In the above I jump 10x10 pixels each time to speed it up. Unlikely to miss text with that amount.
Code: Select all
Let>TextToFind=great
GetWindowPos>Untitled - Notepad,xS,yS
GetWindowSize>Untitled - Notepad,w,h
SetFocus>Untitled - Notepad
Let>xE=xS+w
Let>yE=yS+h
Let>x=xS
Repeat>x
Let>x=x+10
Let>y=yS
Repeat>y
Let>y=y+10
MouseMove>x,y
GetTextAtPoint>x,y,text,cp
Position>TextToFind,text,1,pText
If>pText>0
//found it:
MessageModal>%TextToFind% found at %x%,%y%
Exit>0
Endif
Until>y=yE
Until>x=xE
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 63
- Joined: Thu Dec 10, 2009 8:13 am
Thanks Mtettmar,
But most of time it is hanging...
I am trying in different way by copying the window using "GetWindowTextEx" and spliting it for newlines and search it by using regular pattern matching...
My main motive was to reach the matched text by using arrow keys. That's why I need to get the position of matched string on the screen...
But this code will help me in many ways. I will make use of it.
Thanks a lot..
But most of time it is hanging...
I am trying in different way by copying the window using "GetWindowTextEx" and spliting it for newlines and search it by using regular pattern matching...
My main motive was to reach the matched text by using arrow keys. That's why I need to get the position of matched string on the screen...
But this code will help me in many ways. I will make use of it.
Thanks a lot..