Macro Misbehaving

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
1dave
Newbie
Posts: 2
Joined: Fri Aug 28, 2015 2:58 pm

Macro Misbehaving

Post by 1dave » Fri Aug 28, 2015 3:09 pm

Hi! I am using a trial version of the MacroScheduler and I do not know what to do with my macro, after it loops for a several time, the macro locates the image position and it stops and the mouse cursor is only blinking.

Code: Select all

Label>Start
wait>2

//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_19.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
wait>5

FindImagePos>%BMP_DIR%\image_81.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
wait>1

FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
//Wait for 
WaitScreenImage>%BMP_DIR%\image_102.bmp,0,EXACT

//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_103.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
wait>1
WaitScreenImage>%BMP_DIR%\image_75.bmp,0.7,CCOEFF
FindImagePos>%BMP_DIR%\image_6.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
WaitScreenImage>%BMP_DIR%\image_7.bmp,0.7,CCOEFF
FindImagePos>%BMP_DIR%\image_8.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
WaitScreenImage>%BMP_DIR%\image_9.bmp,0.7,CCOEFF
FindImagePos>%BMP_DIR%\image_10.bmp,SCREEN,0,8,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
WaitScreenImage>%BMP_DIR%\image_11.bmp,0.7,CCOEFF
FindImagePos>%BMP_DIR%\image_12.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
//Ramdom Nickname Generator, 7 Random Characters
Let>SourceString=1234567890aaaaaaeeeeaaaaaeeeaeoooooo
Let>RandomWord=
Let>k=0
Repeat>k
Let>k=k+1
Random>34,RandomResult
MidStr>SourceString,RandomResult,1,Letter
ConCat>RandomWord,Letter
Until>k=12
Let>SK_DELAY=20
send>%RandomWord%
wait>1
Press Enter
WaitScreenImage>%BMP_DIR%\image_13.bmp,0,EXACT
FindImagePos>%BMP_DIR%\image_14.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif

WaitScreenImage>%BMP_DIR%\face.bmp,0,EXACT
wait>3
//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_103.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
wait>2
FindImagePos>%BMP_DIR%\image_105.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif


 wait>3

LClick
wait>2

wait>1
LClick
wait>1
//Wait for
Lclick
Lclick
wait>1
//Wait for
WaitScreenImage>%BMP_DIR%\image_96.bmp,0,EXACT

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_97.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif





//Wait for
WaitScreenImage>%BMP_DIR%\image_86.bmp,0.7,CCOEFF

wait>1
FindImagePos>%BMP_DIR%\image_86.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif

//Wait for
WaitScreenImage>%BMP_DIR%\image_87.bmp,0.7,CCOEFF


wait>1
FindImagePos>%BMP_DIR%\image_87.bmp,SCREEN,0,6,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
Let>SK_DELAY=20
send>davenemesis
wait>1
Press Enter
wait>1

//Wait for
WaitScreenImage>%BMP_DIR%\image_88.bmp,0.7,CCOEFF


wait>1
FindImagePos>%BMP_DIR%\image_88.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
WaitScreenImage>%BMP_DIR%\image_51.bmp,0,EXACT
wait>1

//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_16.bmp,SCREEN,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  wait>1
  LClick
Endif
wait>1
Goto>Start


hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Macro Misbehaving

Post by hagchr » Fri Aug 28, 2015 4:23 pm

Hi, looking at the script the problem could be in a number of places so it is difficult to say.

It is always good to test the script as you go along writing it, then for example, you know it works until row 100 etc and it is easier to isolate problems. Also one good way to find issues is to step through the script line by line (instead of running the script with RUN or F9 you can step through the code line-by-line by pressing F8 and follow the progress of the script and all variables etc in the left-hand side pane.)

Would be interesting to know what you are trying to do (in words), not fully clear from the script (eg are you looking for all the images and expecting to click each one in order or are you just looking for one image (out of several) and clicking on that ...) or combination etc...

1dave
Newbie
Posts: 2
Joined: Fri Aug 28, 2015 2:58 pm

Re: Macro Misbehaving

Post by 1dave » Fri Aug 28, 2015 11:42 pm

hagchr wrote:Hi, looking at the script the problem could be in a number of places so it is difficult to say.

It is always good to test the script as you go along writing it, then for example, you know it works until row 100 etc and it is easier to isolate problems. Also one good way to find issues is to step through the script line by line (instead of running the script with RUN or F9 you can step through the code line-by-line by pressing F8 and follow the progress of the script and all variables etc in the left-hand side pane.)

Would be interesting to know what you are trying to do (in words), not fully clear from the script (eg are you looking for all the images and expecting to click each one in order or are you just looking for one image (out of several) and clicking on that ...) or combination etc...
the script works but after 20-40 loops,it stops randomly. Sometimes it stops in the first Lclick. by the way I use the script for friend invitation in a game, most of the time the script is clicking inside bluestacks. Can I pm you sir hschg and I will send the pictures of the game and those that are in the macro.

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: Macro Misbehaving

Post by hagchr » Sat Aug 29, 2015 7:40 am

Hi,

I note that for some of the WaitScreenImage> you use EXACT instead of CCOEFF and that you are not setting WSI_TIMEOUT to anything. That means if the underlyling image changes so slightly (ie no longer pixel-by-pixel match) then it will continue waiting forever (since that is the default if you do not set WSI_TIMEOUT to anything)

You can set it, eg Let>WSI_TIMEOUT=10 then it would stop waiting after 10 seconds and WSI_TIMEDOUT is returning TRUE, could be one way to isolate where the problem is.

Have you tried using CCOEFF instead of EXACT?

I also note you don't use SetFocus> anywhere. Could anything happen that throws the focus off?


If it doesn't help please feel free to pm me the info.

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