random variable help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Cellinarac
Newbie
Posts: 1
Joined: Sat Aug 10, 2019 12:11 am

random variable help

Post by Cellinarac » Sat Aug 10, 2019 12:28 am

Not sure if this is the right place for this, but I am new to macro scheduler and a little confused. I have been mostly using another macro app (ME) for a couple years or so now, but I got interested in this because of the image recognition it has. the previous was mostly a "screen record" that mostly records mouse and keyboard actions based on screen position that I could edit to my needs. about as "simple" as they come. well, now I am trying to learn something new at my old age and giving this a shot. one of the things I can't figure out is making a random variable related to an image found once it appears, once this image appears, the mouse clicks on a random area of this images location. in ME is was extremely easy to make random variables, I'm finding it seems more than my capabilities in this app. lol. I know this is a totally different "language" than the other app as well because the "code" was a lot easier for me to understand lol setting a random X position was as simple as writing
<VARIABLE SET INTEGER Option="\x05" Destination="%PosX%" Minimum="1207" Maximum="1300"/> and then setting an option "MouseMove: %PosX%, %PosY% Relative to Screen" and it would click in a random area within the given variable. if there is a simple way of doing this I really need the help lol.
Thanks in advance!

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

Re: random variable help

Post by Dorian (MJT support) » Mon Aug 12, 2019 1:18 pm

I think this does roughly what you're looking for. We'll use the Image Recognition Wizard to find the top left corner of an image, add a random number from 1-100 to those coordinates, move the mouse to the newly created coordinates, and then click.

This should get you started and enable you to adapt to your own needs :

Code: Select all

//Find Top Left of the image 
FindImagePos>%BMP_DIR%\image_4.bmp,SCREEN,0.7,0,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  //Generate two random numbers from 1 to 100
  Random>100,addX
  Let>addX=addX+1

  Random>100,addY
  Let>addY=addY+1

  //Add the random numbers to the top left coordinates
  Let>newX=addX+XArr_0
  Let>newY=addY+YArr_0

  //Move the mouse there
  mousemove>newX,newY

  //Click
  LClick
Endif

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