Jump to content
Macro Express Forums

Move mouse to highlight


guli34

Recommended Posts

It depends on which web browser. If you are using IE, it is probably possible to do but tricky. Firefox allows you to select text without a mouse, so it may be easier to automate selecting a word via a macro by sending the appropriate keystrokes, maybe something like this:

 

Type Text: <SHIFT><CONTROL><RIGHT ARROW>

Link to comment
Share on other sites

There is not a command to move to the highlighted area. You can, however, use the Get Pixel Color and some repeat loops to find the highlight. This macro fragment was copied out of a macro that uploads a video to the RevVer video upload site.

 

// Get X Coordinate of button

// Get location of green spot in Revver logo
// N8 = X coordinate  N9 = Y coordinate
Variable Set String %T70% ""
Variable Set Integer %N8% to 25
Variable Set Integer %N9% to 25
Mouse Move Relative to Control %C1%: %N8%, %N9%

// Convert from Relative to Control to Relative to Screen
Variable Set Integer %N8% from Mouse X Position
Variable Set Integer %N9% from Mouse Y Position
Variable Modify Integer: Copy %N8% to %N7%

Repeat Start (Repeat 1000 times)
 Get Pixel: Screen Coords: %N8%,%N9% into %N1%
 If Variable %N1% = 2171169
OR
 If Variable %N1% = 2853994
OR
 If Variable %N1% = 3056505
OR
 If Variable %N1% = 3056249
Variable Set String %T70% "FOUND"
Repeat Exit
 End If
Repeat End

// See if logo was found
If Variable %T70% <> "FOUND"
 Sound Wave File: SystemAsterisk
 Text Box Display: Error: Revver logo not found
 Macro Return
End If

Link to comment
Share on other sites

This example is good when the highlight is always at the same position

-ex: the word Registered Name is highlight move the mouse few pixels to the right on the same line left click 3 times to copy the new name. The question is how to move the mouse few pixels to the right on the same line when the highlighted Registered Name position change randomly or at least go to some few different known positions, and we need to select the Name in relation with its new different line.

Link to comment
Share on other sites

This example is good when the highlight is always at the same position

-ex: the word Registered Name is highlight move the mouse few pixels to the right on the same line left click 3 times to copy the new name. The question is how to move the mouse few pixels to the right on the same line when the highlighted Registered Name position change randomly or at least go to some few different known positions, and we need to select the Name in relation with its new different line.

 

It is possible to write macros to check every pixel on the screen. This assumes that the colour of the selection is unique, which may not be true. These macros are too slow to be of much use, in my opinion. There are, after all, a lot of pixels on a screen: hundreds of thousands or even millions.

 

A macro that visits every pixel along a vertical or horizontal path runs very fast, and is not too hard to script. Instead of pixel colour, it may be possible to search for the changes in the mouse pointer, which changes into a little "hand" when it's hovering over a hypertext link.

 

More challenging, but possible, is a macro that requires you to manually place the mouse cursor close to its destination. Then the macro visits, say, a 40 x 40 pixel block (1600 pixels) looking for a colour or mouse pointer change. These macros run acceptably fast. The most efficient way I can think to do this is to move the mouse pointer in a spiral:

 

1 pixel right.

1 pixel down.

1 pixel left.

1 pixel left.

1 pixel up.

1 pixel up.

1 pixel up.

1 pixel right...

etc.

Link to comment
Share on other sites

This example is good when the highlight is always at the same position...

I'm sorry, I could have showed a much longer example but chose to abbreviate it. Also, due to time constraints, my explanation was also abbreviated. Let me explain a little further.

 

To find a highlight or something that moves you need to establish a reference point. That is, find something that is easier to identify and then work from there. For example, on the RevVer* website there is a button used to start the upload of a video. The button is not always in the same location. I noticed two things. First, there is a logo that is always the same distance from the left edge of the browser window. Second, the button I need to click is always in the same vertical location relative to the logo on the web page.

 

Knowing these relationships I was able to write a macro that first located the logo and then located the button. This same technique can be used to find a highlighted area on the screen.

 

 

* This is neither an endorsement nor criticism of RevVer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...