How to move mouse to whatever text is hilighted.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
tommytx123

How to move mouse to whatever text is hilighted.

Post by tommytx123 » Sat Jan 08, 2005 11:17 pm

Is there a way to move the mouse to the hilited text. Lets say I do a Find on the page and the hiliter finds the text and hilites it. Since I don't know the co-ordinates of the hilited text, I can't use mousemove command.

Bottom line, is I want to search for a word in the link, when it is found and hilited, I want to move the mouse to that coordinate then LClick so that I can follow that link.

If the position of the hiliter cant be obtained, does anyone know a better way to do this.

Thanks
Tom

JRS
Pro Scripter
Posts: 71
Joined: Thu Nov 04, 2004 5:19 am

Post by JRS » Fri Aug 19, 2005 10:48 pm

I have this exact issue I'm grappling with myself. I likewise have
successfully programmed macro Scheduler to do a "Find" and
the match results in a highlighted string match in the window or
dialog. Now what I want to do is determine the relative screen
coordinate of the Find string match. It appears the the result of
the Find is not a redefinition of the Caret and/or Cursor position.
I'm wondering out loud if some kind of pixel color comparison
is the only programming "tack" to pursue for a solution - in other
words search for a certain color pixel in a relative section of the
screen (Hopefully I'm making some semblance of sense here??) ...
or is there a more elegant solution with the existing Macro
Command set I haven't considered? Thanks in advance for any
suggestions.

Joel S.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Aug 19, 2005 11:31 pm

If you are searching on an IE page then this thread/info from support may be helpful http://www.mjtnet.com/usergroup/viewtop ... t+position

JRS
Pro Scripter
Posts: 71
Joined: Thu Nov 04, 2004 5:19 am

Post by JRS » Sat Aug 20, 2005 12:42 pm

Thank you for your reference for the solution finding the X-Y
coordiantes after doing a "find". For what seems to be a
simple issue there is a lot involved with the solution that
involves Document Object Models, creating IE Objects ?? and a couple
hundred thousand Chinese Mandarin words I don't know as
well (making light)

This is not a knock on Macro Scheduler as the solution is indeed
inherently complicated. I'm just thinking (again out loud) if I
do a Find: [Ctrl][f] (lower case f) which is a string search if there's
a match (I'm using Firefox browser) the match on the screen is
highlighted green. On pressing the Escape [Esc] button the highlighted
string match turns to dark blue. The string match always is going to
be in a certain relative part of the window and the fields where the matches occur each have a standard height range for their coordinate.
There are more selections than what shows in the window. If a selection
matches one that is not showing the scrolling is done automatically
on the string search so the match will indeed show in the window.

If you go to http://www.betfair.com there is an All Markets panel (or frame)
for which sport you want to wager on you can see what I mean
here. Once you pick the sport from this panel then you go on to pick the horse race, game, player etc in another frame/panel.

My solution I'm still leaning toward is doing a pixel compare for the
dark blue. If the pixel is blue within a certain range I know the
coordinates to make the selection. (Relative mouse move and Left
Button click via Macro Scheduler)

I'm just wondering (again out loud) for those of you versed in
Macro Scheduler if this solution sounds "weak" or "lame" and I
should really get into the DOM and IE Objects?

Thanks,

Joel.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Aug 20, 2005 3:10 pm

If you are going to use this a lot then I would encourage you to take the time to figure out how to use those functions because you will get a more robust solution.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Aug 22, 2005 3:18 pm

This code works, but I'm not acclaiming it's "elegance". I use it from time to time. I'm not sure what would happen if the text you send to the 'Find' box might exist in another link on the page somewhere. To run this without editing, just open http://www.mjtnet.com/forum/

label>Start
let>Link2Find=Technical / Scripting
setfocus>mjtnet.com :: Index*
wait>1
rem> keystrokes to open the Find dialog box
Press CTRL
Send>f
Release CTRL
wait>1
rem> Here you could send any text or variable.
Send>%Link2Find%
wait>.1
rem> Keystrokes to select the Find button
Press ALT
Send>F
Release ALT
wait>1
rem> Move to the Cancel button to close the Find dialog box
Press TAB
Press ENTER
wait>.5
rem> With the desired text selected by "Find", it only takes one TAB to move the cursor to that text.
Press TAB
rem> voila!, (unless it didn't work for you....) then replace the 'voila' with 'oops'...
Press ENTER

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Aug 22, 2005 3:39 pm

I tested that and it works perfectly for me. Good job SkunkWorks :D

JRS
Pro Scripter
Posts: 71
Joined: Thu Nov 04, 2004 5:19 am

Post by JRS » Tue Aug 23, 2005 3:09 am

Skunkworks,

I tried it myself and it worked for me as well - thanks for posting it.

Joel S.

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