FindImagePos then LClick (works great), but if statement to not click again

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
haxordee
Newbie
Posts: 1
Joined: Wed Jul 10, 2019 9:05 pm

FindImagePos then LClick (works great), but if statement to not click again

Post by haxordee » Wed Jul 10, 2019 9:29 pm

Hello everybody! Macro Scheduler is awesome. Just bought it for a project at work and am having an issue with completing my macro.

I have a project which requires looking at construction plans, and "counting" the number of electrical receptacles on a plan-sheet. The program that I use is simple; every time I see a symbol on the plan, I click on it and the program adds a purple dot, and in the end all of the purple dots are accounted for so I know the total of purple dots.

I used the macro's Image Recognition Wizard to simply find the symbol on the plan-sheet, and left click it. It works wonders, and does exactly what I want it to do. The problem is that once the macro does its job, and adds all the purple dots like I want it to do, it will click the symbols again even though there is now a purple circle overlay over the symbols. Here's the simple code:

Code: Select all

//Find and Left Click Center of [img]https://i.imgur.com/MXBcMI3.png[/img]
FindImagePos>C:\Users\Dad\Downloads\lol.PNG,SCREEN,0.3,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif

//Find and Left Click Center of [img]https://i.imgur.com/QAhclOc.png[/img]
FindImagePos>C:\Users\Dad\Downloads\asdasd.PNG,SCREEN,0.3,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
Endif
The symbols on the plan look like this: Image
After the purple dot is added, they look like this: Image
And like I mentioned before, the macro does a great job of finding these symbols on the plan sheet, left clicking them, thus adding the purple dot. But what I am trying to figure out, is how to add a check within the code so that once it tries to click the symbol again, it will detect a purple pixel and skip/not click the image.

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

Re: FindImagePos then LClick (works great), but if statement to not click again

Post by Marcus Tettmar » Fri Jul 12, 2019 6:36 am

Try changing the matching method from CCOEFF to EXACT so that it does an EXACT match. At the moment it sounds like it is seeing the two as the same thing - CCOEFF is statistical pattern matching and is designed to be tolerant. The purple version is similar, so it sees it as the same thing. That is how it is meant to work as it is designed for finding things like toolbar buttons when backgrounds and resolutions vary. What you need though is to make it look for an EXACT match. See the help file for how the two methods vary and switch to using EXACT.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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