Jump to content

Random mouse click within a space after pixel search


Recommended Posts

Hello all!

I've been having a little trouble getting a script click within a certain area. Basically what I want the script to do is find a pixel color(red for example) and if it finds that color then have it search for another pixel (lets say blue). I want the mouse to move to the blue pixel and then I want it to randomly click within a box I designate around the blue pixel.

I've been playing around the random function and I can get it to click randomly within a box I make but not when there are parameters after a pixel search.

I've also tried using the Mousetrap function and I can't get that to work either.

This is what it looks like

while 1

If $Active = 1 Then

$checkforpixelA = Pixelsearch( 50, 488, 292, 645, 0x015089)

$checkforpixelB = Pixelsearch( 273, 765, 914, 954, 0xEBF3FB)

if isarray($checkforpixelA Then

mousemove($checkforpixelB [0], $checkforpixelB[1], 1)

sleep(1000)

EndIf

EndIf

WEnd

Help please.au3

Edited by Spitty13
Link to comment
Share on other sites

Explain this "but not when there are parameters after a pixel search"

How certain are you that $checkforpixelB is an array?

Honestly I'm not even sure if the array function is needed. The part posted is just a portion of the whole so it may seem extraneous.

The main thing I want is for the pixel search to find a pixel and then have a "box" built around that pixel. I then want the mouse click function to randomly click in that box. Does something like that exist?

Link to comment
Share on other sites

Well thanks for helping. I still can't figure it out though.

Is there a way to put a random number after a variable

So basically is there another way to write this

$checkforpixelB = Pixelsearch( 273, 765, 914, 954, 0xEBF3FB)

mousemove($checkforpixelB [0], $checkforpixelB[1], 1)

re-written so it finds a random number + or - 100 what the pixel search found? Possibly like this?

mousemove($checkforpixelB [(random(1,100,1)], $checkforpixelB[(random(1,100,1)], 1)

Maybe I'm just asking for something it can not do

Edited by Spitty13
Link to comment
Share on other sites

You are passing a variable to MouseMove that most likely does not exist.

mousemove($checkforpixelB [(random(1,100,1)] < the number here has a 100/1 chance of being 1, which is the only possible correct element of the array with your random function (MouseMove on success returns [0] and [1].

You need something like mousemove($checkforpixelB[0] + (random(1,100,1), $checkforpixelB[1] + (random(1,100,1)) but with better logic.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...