Mousemove to pixel color

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
bb42392
Newbie
Posts: 3
Joined: Tue Mar 18, 2008 9:12 pm

Mousemove to pixel color

Post by bb42392 » Tue Mar 18, 2008 9:20 pm

Hi,
I just started using Macro Scheduler, and so far I've had no issues. However, recently I wanted to try writing a script involving mouse moving and clicking on certain areas of the screen. I know how to find the pixel color of these areas, but is it possible to make the mouse move to this pixel color once it has been found and then click on it? I've already tried using coordinates to move the mouse to these areas, but it doesn't work because the background screen environment is constantly changing and moving around.
Thanks for all your help

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

Click a pixel based upon color value using nested loops

Post by adroege » Wed Jun 09, 2010 9:53 pm

This should give you some ideas....

Code: Select all


GetScreenRes>MaxX,MaxY

//Set this to a color value of a pixel you want clicked
Let>TargetColor=1619513

Let>x=0
Repeat>x
  Add>x,1
  Let>y=0
  Repeat>y
    Add>y,1
    GetPixelColor>x,y,result
	If>result=TargetColor
	   MessageModal>Found it!  %x%  %y%
	   //Click on it if you want
	   //MouseMove>x,y
	   //LClick
	   Goto>Exit
    Endif
  Until>y=MaxY
Until>x=MaxX

Label>Exit


gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Wed Jun 09, 2010 10:17 pm

FindImagePos might be the simplest way. The "needle file" can be a small patch of the color you are looking for - it can be as small as a single pixel. then the command will find all occurances of that color for you without needing to use a loop.

Gale

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

Post by Marcus Tettmar » Fri Jun 11, 2010 9:43 am

The quickest way is to use the FindColor library which you can download from: http://www.mjtnet.com/plugins.htm

Give it a colour and a rectangle to search within and it will return the position of the pixel with that colour. It is much faster than using GetPixelColor in a loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

fightcancer
Macro Veteran
Posts: 249
Joined: Fri Apr 15, 2005 8:32 am

Re:

Post by fightcancer » Mon Aug 31, 2020 5:22 pm

Sorry for resurrecting an old thread.

gdyvig wrote:
Wed Jun 09, 2010 10:17 pm
FindImagePos might be the simplest way. The "needle file" can be a small patch of the color you are looking for - it can be as small as a single pixel.
Is that still true? I have not had luck using FindImagePos for a 1x1 BMP.

Marcus Tettmar wrote:
Fri Jun 11, 2010 9:43 am
The quickest way is to use the FindColor library which you can download from: http://www.mjtnet.com/plugins.htm

Give it a colour and a rectangle to search within and it will return the position of the pixel with that colour. It is much faster than using GetPixelColor in a loop.
Where could I find FindColor library please? I can't find it using a Google search, and the link doesn't work any more. Thanks in advance!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Mousemove to pixel color

Post by JRL » Mon Aug 31, 2020 6:46 pm

No idea where the find color library might be or even how it works.

I always use THIS.

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