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
Mousemove to pixel color
Moderators: Dorian (MJT support), JRL
Click a pixel based upon color value using nested loops
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
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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.
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Macro Veteran
- Posts: 252
- Joined: Fri Apr 15, 2005 8:32 am
Re:
Sorry for resurrecting an old thread.
Is that still true? I have not had luck using FindImagePos for a 1x1 BMP.
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!Marcus Tettmar wrote: ↑Fri Jun 11, 2010 9:43 amThe 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.