automating task with image trigger

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
eycaxit
Newbie
Posts: 1
Joined: Wed May 19, 2021 1:55 am

automating task with image trigger

Post by eycaxit » Thu May 20, 2021 5:38 am

Hi I know very little about writing scripts, I wrote a basic loop to click on two places once the set image is found.
Image
So once the red timer is gone it will click on the Purchase, if click before the timer the game add a cooldown.
Image
then I press on Confirm after.

Code: Select all

MoveWindow>x x x,36,1221

Label>start

ScreenCapture>844,1510,880,1526,%TEMP_DIR%\screenrect.bmp
//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_1.bmp,%TEMP_DIR%\screenrect.bmp,0.85,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  Let>count=1
  Repeat>count
  MouseMove>{%XArr_0%+1396},{%YArr_0%+1996}
  LClick
  MouseMove>{%XArr_0%+1013},{%YArr_0%+1750}
  Wait>0.16
  LClick
  Add>count,1
  Until>count=3
  else
  Goto>start
Endif
Goto>start
i make the clicking repeat 3 times just to make sure it clicks. I have succeed only 30% of the time, not sure if it the latency or other players just got faster fingers at clicking. I found that 0.16sec is a sweet spot to click purchase after confirm. Any suggestions are welcome :mrgreen:

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: automating task with image trigger

Post by Dorian (MJT support) » Thu May 20, 2021 10:10 am

Maybe other players are automating it too, if it's a race to click it.

Or maybe yours is working slightly too fast. Sometimes we might see an element before everything has finished loading or processing. I'd start by adding a small delay between the two clicks.

If that doesn't help maybe experiment with waiting for a fraction of a second after If>NumFound>0. They may even have anti-bot measure in there where it ignores anything that's too fast. It's quite hard to say, but your script itself looks fine.
Yes, we have a Custom Scripting Service. Message me or go here

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