I have 2 questions i hope you guys help me with

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: I have 2 questions i hope you guys help me with

Post by ocnuybear » Mon Sep 03, 2018 1:33 pm

Not sure if this is what you want, but try this - just replace the picture paths & names please:

Code: Select all

//How many times to click on same picture
Let>ClickTimes=10
Let>Timeout=5

Gosub>FindImage,C:\Users\x\Desktop\pic1
Gosub>FindImage,C:\Users\x\Desktop\pic2
Gosub>FindImage,C:\Users\x\Desktop\pic3
Gosub>FindImage,C:\Users\x\Desktop\pic4
Gosub>FindImage,C:\Users\x\Desktop\pic5
Gosub>FindImage,C:\Users\x\Desktop\pic6

SRT>FindImage
  Let>x=0
  While>x<%Timeout%
    Let>x=x+1
    Let>Clicked=0
    While>%Clicked%<%ClickTimes%
      FindImagePos>%FindImage_var_1%,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
      IF>NumFound>0
        Let>Clicked=%Clicked%+1
        Let>x=0
        MouseMove>XArr_0,YArr_0
        LClick
      ENDIF
      IF>NumFound=0
        Let>%Clicked%=%ClickTimes%
      ENDIF
    EndWhile
  EndWhile
END>FindImage

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Wed Sep 05, 2018 10:35 am

ocnuybear wrote:
Mon Sep 03, 2018 1:33 pm
Not sure if this is what you want, but try this - just replace the picture paths & names please:

Code: Select all

//How many times to click on same picture
Let>ClickTimes=10
Let>Timeout=5

Gosub>FindImage,C:\Users\x\Desktop\pic1
Gosub>FindImage,C:\Users\x\Desktop\pic2
Gosub>FindImage,C:\Users\x\Desktop\pic3
Gosub>FindImage,C:\Users\x\Desktop\pic4
Gosub>FindImage,C:\Users\x\Desktop\pic5
Gosub>FindImage,C:\Users\x\Desktop\pic6

SRT>FindImage
  Let>x=0
  While>x<%Timeout%
    Let>x=x+1
    Let>Clicked=0
    While>%Clicked%<%ClickTimes%
      FindImagePos>%FindImage_var_1%,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
      IF>NumFound>0
        Let>Clicked=%Clicked%+1
        Let>x=0
        MouseMove>XArr_0,YArr_0
        LClick
      ENDIF
      IF>NumFound=0
        Let>%Clicked%=%ClickTimes%
      ENDIF
    EndWhile
  EndWhile
END>FindImage
i'm trying to use the command waitforscreenimage since it's better for my sitautino

WaitScreenImage>%BMP_DIR%\image_1.bmp,0.7,CCOEFF,NumFound,XArr,YArr
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
EndIf

but i can't seem to find a way to fix it to make the mouse click on the picture because it gives me mouse errors
thanks for your help

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

Re: I have 2 questions i hope you guys help me with

Post by Marcus Tettmar » Wed Sep 05, 2018 10:41 am

Your syntax for WaitScreenImage is wrong. Please read the WaitScreenImage topic in the manual (hit F1 or Help menu). Or online version:

https://www.mjtnet.com/manual/waitscreenimage.htm

So you could just do:

Code: Select all

​WaitScreenImage>%BMP_DIR%\image_1.bmp,0.7,CCOEFF,xPos,yPos
​If>WSI_RESULT>0
   MouseMove>xPos,yPos
​   LClick​
​Endif
WaitScreenImage is just a wrapper for a loop with FindImagePos inside it. Think about it. It looks for an image, if not found, loops back up and looks again, rinse repeat, until it's found. So it's exactly the same as ocnuybear suggested above. Just less code.

You probably also want to check the timeout value in case it never finds it. You probably don't want the macro waiting forever if it never shows up and probably want to error out gracefully.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

levelcap
Newbie
Posts: 17
Joined: Sat Sep 01, 2018 8:26 am

Re: I have 2 questions i hope you guys help me with

Post by levelcap » Wed Sep 05, 2018 1:47 pm

thanks for the help guys! finally figured that i needed 2 commands to make this works

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