Basically what I want to do is have 5 actions but I want macro scheduler to randomly pick one of these actions each time any idea how I can do this?
Quick example
label>start
action 1
action 2
action 3
Randomly pick one of the 3 actions and execute it.
Goto>Start
Pick a random action?
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Pick a random action?
Yes, for that we can use a combination of Random and SRT (subroutines).
Code: Select all
//Generate a random number
Random>5,Result
Let>Result=Result+1
//Call SubroutineNumber
gosub>routine%Result%
srt>routine1
messagemodal>1
END>routine1
srt>routine2
messagemodal>2
END>routine2
srt>routine3
messagemodal>3
END>routine3
srt>routine4
messagemodal>4
END>routine4
srt>routine5
messagemodal>5
END>routine5
Re: Pick a random action?
I sent you a private message.
Re: Pick a random action?
I still need help with this the code above is not what I need lets say I have two images right? I want the bot to click one of the images at random each time if that makes sense?
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Pick a random action?
I replied to your PMs but there's no inherent reason we need to be discussing this privately as no sensitive information is involved. So let's continue here.
The same rule applies. MessageModal was just to demonstrate how to do what you asked. That's where you put your code for each action. Use the image recognition Wizard to generate your IR code. The script at the bottom of this reply will do as you ask and can be expanded for as many images as you like.
Initially you wanted to randomize 5 actions so I went with a subroutine. Please read the helpfile section I linked to regarding Subroutines. It's explained in detail there.
If it's only two actions, this could simply be achieved with an If/Else/Endif. The result will either be 1 or 2. If it's 1, find and click image1. If it isn't, it must be 2, so find and click image2 :
To cut it down even further :
The same rule applies. MessageModal was just to demonstrate how to do what you asked. That's where you put your code for each action. Use the image recognition Wizard to generate your IR code. The script at the bottom of this reply will do as you ask and can be expanded for as many images as you like.
Initially you wanted to randomize 5 actions so I went with a subroutine. Please read the helpfile section I linked to regarding Subroutines. It's explained in detail there.
If it's only two actions, this could simply be achieved with an If/Else/Endif. The result will either be 1 or 2. If it's 1, find and click image1. If it isn't, it must be 2, so find and click image2 :
Code: Select all
//Generate a random number
Random>2,Result
Let>Result=Result+1
If>result=1
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound1,CCOEFF
If>NumFound1>0
MouseMove>XArr_0,YArr_0
LClick
Endif
else
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound2,CCOEFF
If>NumFound2>0
MouseMove>XArr_0,YArr_0
LClick
Endif
endif
Code: Select all
//Generate a random number
Random>2,Result
Let>Result=Result+1
If>result=1
//Action 1
MessageModal>1
else
//Action 2
MessageModal>2
endif
Code: Select all
//Generate a random number
Random>2,Result
Let>Result=Result+1
//Call SubroutineNumber
gosub>routine%Result%
srt>routine1
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound1,CCOEFF
If>NumFound1>0
MouseMove>XArr_0,YArr_0
LClick
Endif
END>routine1
srt>routine2
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound2,CCOEFF
If>NumFound2>0
MouseMove>XArr_0,YArr_0
LClick
Endif
END>routine2