Jump to content

Tried Color Clicking Macro ..but having problems


birenD
 Share

Recommended Posts

Sleep (10000)

$pos = MouseGetPos()

$var = PixelGetColor( $pos[0] , $pos[1] )

MsgBox(0,"Got It", "All Set")

Sleep(5000)

$q = 1

$t = 2000

Do

$cord = PixelSearch(97,261,347,437,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(97,437,347,658,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(347,132,497,437,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(347,437,497,658,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(497,132,647,326,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(497,478,647,721,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(647,132,833,437,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(647,437,833,721,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(833,132,1050,437,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$cord = PixelSearch(833,437,1050,721,$var,10)

MouseClick("Left",$cord[0],$cord[1])

Sleep($t)

$q = $q + 1

Until $q = -10

What i did here was take the screen of what i was applying this to.. and broke it apart.. because i did not want the bot to repeatedly click the same spot for a certain amount of time.. and waiting for that time took to long and wasted what the program could have been doing.. so if i broke it up i thought by the time the porgram returned to looking at that one spot.. it was free to click.. THE PROBLEM IS if the pixel comes back with @error = 1 the program just stops.. i thought about using If Else If statements but seems like it wont work.. im new to this can someone help me out

Link to comment
Share on other sites

i thought about using If Else If statements but seems like it wont work.

consider switch case statement.

or just explain it a little bit more clearly in a less complicated way. i feel like not reading it. sorry.. :|

Link to comment
Share on other sites

Ok, Not sure if I get what you want. You know that if a pixel of the specified colour cannot be found it does not return an array for the x,y value, but sets @error instead. If you only want to click if he found the pixel change your code as shown:

...
Do
$cord = PixelSearch(97,261,347,437,$var,10)
If Not @error Then
    MouseClick("Left",$cord[0],$cord[1])
    Sleep($t)
EndIf
$cord = PixelSearch(97,437,347,658,$var,10)
If Not @error Then
    MouseClick("Left",$cord[0],$cord[1])
    Sleep($t)
EndIf
...
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...