New To This Macro Need Help
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
New To This Macro Need Help
Hi So i am new to this program and have a couple of questions and help also.
I am trying to make a script and hit a couple of ded ends.
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0,GoSub>DO
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0,chest
Goto>check
SRT>DO
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_4.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LDblClick
it says cant find do?
I am trying to make a script and hit a couple of ded ends.
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0,GoSub>DO
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0,chest
Goto>check
SRT>DO
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_4.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LDblClick
it says cant find do?
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
Take out the GoSub>
If you are doing the IF statement on 1 line, you don't need it.
If>NumFound>0,DO
If you are doing the IF in a multi line format, you do.
If>NumFound>0
GoSub>DO
Endif
If you are doing the IF statement on 1 line, you don't need it.
If>NumFound>0,DO
If you are doing the IF in a multi line format, you do.
If>NumFound>0
GoSub>DO
Endif
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
thanks Jerry it worked.. I hit one more ded end need some help
Label>check
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
GoSub>help
Endif
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
GoSub>chest
Endif
Goto>check
ok so the gosub works now. now the problem is I have 2 things to look for. the way its running is looks for one once one if found looks for the second.
What if i need it to look for eather one at the same time. Now if i do take out the endif it does it but gives me an error endif/else. Can anyone help
Label>check
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
GoSub>help
Endif
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
GoSub>chest
Endif
Goto>check
ok so the gosub works now. now the problem is I have 2 things to look for. the way its running is looks for one once one if found looks for the second.
What if i need it to look for eather one at the same time. Now if i do take out the endif it does it but gives me an error endif/else. Can anyone help

-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
Try something like this...
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,Image_1_Found,CCOEFF
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,Image_2_Found,CCOEFF
If>I{(%Image_1Found%>0) or (%Image_2_Found%>0)}
GoSub>YourSRT
endif
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,Image_1_Found,CCOEFF
FindImagePos>%BMP_DIR%\image_8.bmp,WINDOW:BlueStacks App Player,0.7,1,XArr,YArr,Image_2_Found,CCOEFF
If>I{(%Image_1Found%>0) or (%Image_2_Found%>0)}
GoSub>YourSRT
endif
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
Jerry with that it looks like it will go to one location... i am looking for something like this
if image gosub do
if image2 gosub do2
each image should direct to a different SRT
if image gosub do
if image2 gosub do2
each image should direct to a different SRT
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
Yes it would go to 1 location
"What if i need it to look for either one at the same time."
You have to look for 1 image at a time but can do the 2nd immediately after the 1st one
You don't need to use the multi line style 'If' statement if this is all you want
FindImagePos>,,,,,,,,Image1,,,
FindImagePos>,,,,,,,,Image2,,,
if image1>0,DO1
if image2>0,DO2
"What if i need it to look for either one at the same time."
You have to look for 1 image at a time but can do the 2nd immediately after the 1st one
You don't need to use the multi line style 'If' statement if this is all you want
FindImagePos>,,,,,,,,Image1,,,
FindImagePos>,,,,,,,,Image2,,,
if image1>0,DO1
if image2>0,DO2
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
Jerry thanks for being helpful honestly
..
but what about the gosub?
can i do this:
if image1>0,GoSub>DO1
if image2>0,GoSub>DO2

but what about the gosub?
can i do this:
if image1>0,GoSub>DO1
if image2>0,GoSub>DO2
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
This gets back to your original question.
If you are doing an "If" statement in the 1 line format, take out "GoSub>".
Use this:
if image1>0,DO1
if image2>0,DO2
NOT THIS
if image1>0,GoSub>DO1
if image2>0,GoSub>DO2
If you are doing an "If" statement in the 1 line format, take out "GoSub>".
Use this:
if image1>0,DO1
if image2>0,DO2
NOT THIS
if image1>0,GoSub>DO1
if image2>0,GoSub>DO2
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
Is there a way to use ifgosub?
example want to check for 5 things
label check
if image1 gosub do1
if image2 gosub do2
if image3 gosub do3
if image4 gosub do4
if image5 gosub do5
goto check
SRT>do1
do whar ever
end>do1
SRT>do2
do whar ever
end>do2
SRT>do3
do whar ever
end>do3
SRT>do3
do whar ever
end>do3
SRT>do4
do whar ever
end>do4
SRT>do5
do whar ever
end>do5
this way every time it returns to check its not going to start at top but to go back at a section it already was.
example want to check for 5 things
label check
if image1 gosub do1
if image2 gosub do2
if image3 gosub do3
if image4 gosub do4
if image5 gosub do5
goto check
SRT>do1
do whar ever
end>do1
SRT>do2
do whar ever
end>do2
SRT>do3
do whar ever
end>do3
SRT>do3
do whar ever
end>do3
SRT>do4
do whar ever
end>do4
SRT>do5
do whar ever
end>do5
this way every time it returns to check its not going to start at top but to go back at a section it already was.
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
OK Jerry i got it
.. I think i understand what your saying i can do that way also...
//Find and Double Left Click To the Right of the
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0,8,XArr,YArr,NumFound,EXACT
If>NumFound>0
MouseMove>{%XArr_0%+380},YArr_0
LDblClick
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_3.bmp,0,EXACT
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_3.bmp,WINDOW:BlueStacks App Player,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
MouseMove>XArr_0,YArr_0
LDblClick
Endif
ok so i have that and works great but i dont like that it has to wait for image, if i take the wait out it never goes in to clicking it.

//Find and Double Left Click To the Right of the
FindImagePos>%BMP_DIR%\image_1.bmp,WINDOW:BlueStacks App Player,0,8,XArr,YArr,NumFound,EXACT
If>NumFound>0
MouseMove>{%XArr_0%+380},YArr_0
LDblClick
Endif
//Wait for
WaitScreenImage>%BMP_DIR%\image_3.bmp,0,EXACT
//Find and Double Left Click Center of
FindImagePos>%BMP_DIR%\image_3.bmp,WINDOW:BlueStacks App Player,0,1,XArr,YArr,NumFound,EXACT
If>NumFound>0
MouseMove>XArr_0,YArr_0
LDblClick
Endif
ok so i have that and works great but i dont like that it has to wait for image, if i take the wait out it never goes in to clicking it.
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
To clarify the scenario:
Is Image2 a result of the mouse click in the Image1 code?
Or
Are you expecting Image1, or Image 2 or none. (I know you may have more images just reducing the number for clarity)
If Image1 code causes Image2, then it is reasonable to wait for Image2 to render.
Also, if this is how it works, you should reset your variables (or use different variables) for NumFound, X_Arr and Y_Arr
If you are expecting Image1, or Image2, or nothing, then you shouldn't have to wait.
If>Image1=0 then it will immediately go to next statement
If>Image2.....
Is Image2 a result of the mouse click in the Image1 code?
Or
Are you expecting Image1, or Image 2 or none. (I know you may have more images just reducing the number for clarity)
If Image1 code causes Image2, then it is reasonable to wait for Image2 to render.
Also, if this is how it works, you should reset your variables (or use different variables) for NumFound, X_Arr and Y_Arr
If you are expecting Image1, or Image2, or nothing, then you shouldn't have to wait.
If>Image1=0 then it will immediately go to next statement
If>Image2.....
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
image2 is the result of image1 being pressed.. but some times it might not throw an image2 at me. so if no image2 comes in to play i want it to continue to next step.
let me explain what i am trying to do...
I want to apply an item
first time it just applies it without any images
now since there is a possibility it might try to apply it the second time i want to hit cancel.
let me explain what i am trying to do...
I want to apply an item
first time it just applies it without any images
now since there is a possibility it might try to apply it the second time i want to hit cancel.
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
It sounds like a Wait is reasonable but you could adjust the length of the wait so it is a minor factor in the duration of the script.
-
- Newbie
- Posts: 17
- Joined: Thu Mar 05, 2015 1:45 pm
Re: New To This Macro Need Help
Jerry another question for you lol
ok so on the screen there are 2 images both the same so if that is true go to somewhere.
is that possible to do?
ohh and those 2 images would be a result of clicking an image if that matters
ok so on the screen there are 2 images both the same so if that is true go to somewhere.
is that possible to do?
ohh and those 2 images would be a result of clicking an image if that matters
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
Re: New To This Macro Need Help
Something like this will go through and click as many as copies of this image that it finds.
If there is only 1, then it clicks once.
But if there are multiple images, then it will click multiple times.
The arrays are 0 based so the LoopCnt needs to start at 0
If there is only 1, then it clicks once.
But if there are multiple images, then it will click multiple times.
Code: Select all
If>NumFound>0
Let>LoopCnt=0
Repeat>LoopCnt
MouseMove>XArr_%LoopCnt%,YArr_%LoopCnt%
LDblClick
Let>LoopCnt=LoopCnt+1
Until>LoopCnt,NumFound
Endif
The arrays are 0 based so the LoopCnt needs to start at 0