Jump to content
Macro Express Forums

Move mouse to a specific color (pixel) within a highlighted area

Recommended Posts

I have been using Macro Express Pro 4 to help me navigate my medical record software. However, I am having difficulty creating one of the macros and seek your advice/assistance.


Using the up and down arrows I am able to highlight (in green) each individual drug. I can then use the spacebar to place a check box beside the medication listed. However, to click on the information icon (blue “i”) I have to use the mouse to hover over it (i.e. there is no keyboard short cut available).


Is there a way to create a macro that looks for the green highlighted area and then the blue “i” icon located within the green area and moves the mouse over it?

  • Green Pixel Color = 11141041
  • Blue Pixel Color = 12284784


Note: the green highlighted area will always be random distances from the top left of the active window, however the location of the blue “i” icon will always be in the same location within the green highlighted area. At any given time there could be multiple checked boxes within the active window, but there will always be only one green highlighted area.


Unfortunately, I have carpal tunnel in my right hand and therefore need to eliminate all unnecessary mouse activities.


Thank you in advance for you help.



P.S. After reviewing some of the other discussion forums, is it possible to do a vertical pixel search (as all of the blue "i" icons line up) and if a green highlighted pixel is found, move the mouse to the blue "i" icon directly below?


Macro Express - Move mouse to specific colored area.jpg

Link to comment
Share on other sites

I have never make a 'pixel searching' macro, but I believe others have.  Like you said, if the "i" icon is always that same distance from the left, then that helps.  


I wonder though, what happens if you navigate this window with different keyboard keys?  Does Tab Tab Tab have an effect?  Or what about Spacebar  or Alt+S? 

Link to comment
Share on other sites

Thank you for your response. Unfortunately, there are no keyboard keys available within the program.


I did find the following (from ACantor) within the discussion forum from a few years back.








<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="100" _COMMENT="Initial x coordinate"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%y%" Value="300" _COMMENT="Initial y coordinate"/>
<VARIABLE SET STRING Option="\x00" Destination="%TargetColour%" Value="255" NoEmbeddedVars="FALSE" _COMMENT="Target pixel colour 255 = RED of the words \"Macro Stop\" in the MEP \"Script Editor\""/>
<REPEAT START Start="1" Step="1" Count="400" Save="FALSE"/>
<MOUSE MOVE Option="\x01" X="%x%" Y="%y%" _PROMPT="0x000A"/>
<GET PIXEL COLOR Option="\x00" Rel_To_Screen="TRUE" Destination="%PixelColour%"/>
<IF VARIABLE Variable="%PixelColour%" Condition="\x00" Value="%TargetColour%" IgnoreCase="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%" _COMMENT="Increase the value of x by 1"/>

Link to comment
Share on other sites

I think the key to easily searching for a blue pixel in the "I" icon hinges on whether this Macro Express instruction works in the application. (It works in some programs, but not others):


Mouse Move: To the Text Cursor Position


See if the instruction causes the mouse pointer to jump somewhere within the selected item. Try it both with the checkbox checked and unchecked.  If it works, report back!


Another approach which is more brute force and computational. In outline...


1. Search down from the top of the window in one pixel increments to find the top of the green selection.

2. Continue to search down to to find the bottom of the green selection -- the background colour of a non-selected item.

3. The centre of the target icon appears to be a fixed distance from the bottom of the selection. Or perhaps a fixed proportion of the height of the selection.

4. Move the mouse cursor "north" by that distance.

5. Search right, starting from the left edge of the window, in one pixel increments to find the blue icon.

6. Click!



Link to comment
Share on other sites

Hi Joe,


It would be useful to know what OS you're running, as pixel hunting with MEP has become significantly slower for me under Windows 10, although I still end up resorting to it quite frequently.


I'd echo @acantor's approach, with a couple of other points.


Assuming that your screenshot occupies about half the screen height, I'm guessing your green band has a depth of say 50 pixels. So you could first search for its presence very quickly in say 40 px increments. Any value a few px fewer than its depth.


Having next found its precise top (using 1 px jumps) as @acantor outlined, you should be able to jump straight to the  blue icon clickable region, by calculation alone I think.


BTW, when posting a screenshot in a topic about pixel colours and positions it's better to use say a BMP or PNG file type. Yours looks like a JPG, the colours of which are never faithful due to artifacts caused by compression. Try the mouse locator over your image in this thread to see the many different colours in your green band.


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.

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.

  • Create New...