GetTextInRect in Firefox 4

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

GetTextInRect in Firefox 4

Post by Dj Telo » Fri Mar 25, 2011 8:38 pm

Hello everyone.

Here is my my problem: I have recently updated from Firefox 3.5 to Firefox 4 and the GetTextInRect command is no longer working in the scripts that worked before.

I have tested the command defining large regions from where to get text, but MDL>text is blank when my macro runs.

Does anybody know what the problem might be?

Thanks in advanced and sorry for my English.

katalonija2
Junior Coder
Posts: 21
Joined: Thu Mar 10, 2011 6:49 pm

Post by katalonija2 » Sat Mar 26, 2011 4:57 am

I never successfully got text from javascript pop windows.

Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

Post by Dj Telo » Fri Apr 01, 2011 9:39 am

Anyone knows? :roll:

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

Post by Marcus Tettmar » Fri Apr 01, 2011 12:59 pm

It is quite possible that FireFox has changed the way they render text and may not be calling any of the Windows text out functions to do so. A la Chrome.

I haven't tried it yet so don't know for sure. But since it worked in 3.5 and not in 4 that would be my suspicion.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Post by adroege » Fri Apr 01, 2011 1:52 pm

Try giving the popup window the focus and then doing


Press Ctrl
Wait>0.1
Send>a
Wait>0.1
Release Ctrl

Wait>0.1
Press Ctrl
Wait>0.1
Send>c
Wait>0.1
Release>Ctrl
Wait>0.1

GetClipBoard>result

Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

Post by Dj Telo » Fri Apr 01, 2011 3:11 pm

Thank you both for your comments.

Adroege, that way it works but I get absolutely all the text in the window, and I only want a little text placed in an specific place. That is why I used GetTextinRect, to be able to pick the text exactly where I want.

This way I would have to work in another algorithm to process the text from the clipboard.

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

Post by adroege » Fri Apr 01, 2011 3:27 pm

This way I would have to work in another algorithm to process the text from the clipboard.

Usually this is as simple as:

Code: Select all

Let>Clipboardtext=Blah Blah Blah Blah Success!  Blah Blah Blah Blah
Let>StringToSearchFor=Success!

Position>StringToSearchFor,Clipboardtext,1,result

If>result>0
   MessageModal>The result was successfull !
Else
   MessageModal>Something bad happened
Endif

Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

Post by Dj Telo » Fri Apr 01, 2011 5:02 pm

I will have to take a look at that when I have time, Thank you so much! ;)

Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

Post by Dj Telo » Fri Apr 01, 2011 5:08 pm

" item1
ratio 64 / 115"

With your method, I get something like the text above.

Now I need to select only the ratio and remove the spaces so I can calculate 65/115. Any more help?

Thanks again!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Apr 01, 2011 6:17 pm

Hi Dj Telo,

You're close. At this point, you could use a RegEx to isolate your target... try the code below:

Code: Select all

Let>data= item1%CRLF%ratio 64 / 115
MDL>data

StringReplace>data,%SPACE%,,data
MDL>data

Let>matches_1=
Let>pattern=(?<=ratio)[0-9]{1,3}[/]{0,1}[0-9]{1,3}
RegEx>pattern,data,0,matches,num,0

MDL>matches_1
I used StringReplace> to remove any spaces from the data just to make writing of the Regex pattern easier.

The first part of the pattern is using a regex feature called Positive Lookbehind:

(?<=ratio)

This tells it that the word ratio must preceed the numbers... but it will not be included in the match. If you are lucky and the entire blob of text only ever uses the word ratio once, right before your number, you can probably dispense with any other code you might be using to isolate your numbers and just use this regex against the entire text blob. Here's a useful link to learn more about Positive Lookbehind: http://www.regular-expressions.info/lookaround.html

I did not know if the / will always appear in the number or not so I wrote the pattern so that it would be optional i.e. the following would all match:

1/1
1/22
22/1
22/22
22/333
333/22
333/333
22
333
4444
56555
666666

However the following would not match:

/1
/22
/333
1/
22/
333/

You can of course adjust the pattern to be able to handle the range of data you'll have to parse.

Good luck and take care
Last edited by jpuziano on Fri Apr 01, 2011 6:51 pm, edited 1 time in total.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Dj Telo
Junior Coder
Posts: 24
Joined: Sun Mar 21, 2010 7:27 pm

Post by Dj Telo » Fri Apr 01, 2011 6:45 pm

That is getting challenging. :D

I will try to finish my script in a few weeks when my university exams will be finished.

Thank you all for your help!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Apr 01, 2011 6:57 pm

Dj Telo wrote:That is getting challenging. :D
Sure... but it doesn't even get interesting until it gets challenging... :wink:

Good luck in your exams and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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