Sign in to follow this  
Followers 0
shadowsin

Pixel Search help

6 posts in this topic

ok so i am making a bot for a game how do i make the mouse move to the pixel i want (basically the npc that is wearing that color dress) im still learning so dont flame and help plz

Share this post


Link to post
Share on other sites



ok so i am making a bot for a game how do i make the mouse move to the pixel i want (basically the npc that is wearing that color dress) im still learning so dont flame and help plz

No flame, look at PixelSearch() in the help file, you'll see it gives an array of coords when the color is found.

[0] = x - coord

[1] = y - coord

So, if we wanted to find a specific color in a 100x100 square starting at 0 x and 0 y it would look something like this:

While 1 ; The beginning of a loop to keep looking
    Local $aPix = PixelSearch(0, 0, 100, 100, 0xFF0000) ;0xFF0000 is the color red
    If IsArray($aPix) Then ; A conditional statement telling it to only click if the color is found
        MouseClick('primary', $aPix[0], $aPix[1], 1, 1)
        ExitLoop ; Now the color was found, it will exit the loop and continue on with whatever else you've written
    EndIf
    Sleep(10);Rest the PC
WEnd;End Of loop now start over

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

it didnt work. i basically want it to move the mouse from left to right going down till it finds the color was that wat it was supposed to do?

Edited by shadowsin

Share this post


Link to post
Share on other sites

do i have to put anything specific or is $apix a default thing? i have looked at other codes and they have other things. and thx for helping becuase that helped me a lot

the $apix "thing" is a variable that will hold the array returned if the color is found. It can be anything that starts with a '$'. But the syntax I used for MouseClick() must be used ([0],[1] with the variable you used to hold the array returned in front of them).

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

it didnt work. i basically want it to move the mouse from left to right going down till it finds the color was that wat it was supposed to do?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Note, this isn't anything against you personally, nor is it a flame, it is merely a thing to help you be more effective in getting your desired results in future posts.

it didnt work. i basically want it to move the mouse from left to right going down till it finds the color was that wat it was supposed to do?

it didnt work. i basically want it to move the mouse from left to right going down till it finds the color was that wat it was supposed to do?

Now come on, is it really necessary to post the SAME EXACT REPLY twice? and its not even a double post, they are like 10 hours apart

im still learning so dont flame and help plz

Whatever your scripting experience, it is not an excuse to not use common sense. scripting itself is all about logic, and if you can't logically string together a post capable of explaining both your problem, what you have tried, and the results of your attempts, then you SHOULD NOT be posting. If you have made no attempt, don't expect us to just give you a code because you can smack your keyboard and push "Add Reply"

In the future, follow this order of operations before posting

  • Ok, so you tried something once, and got an error. Uh-Oh, What now?
  • Read the help file
  • Find a the chunk of your code that you believe to contain the error
  • Find all the lines in that segment of code that contain information that if changed, could affect your code
  • For each line, change some piece of the previous information(From step 2) Test your script, and if you find that this information is not causing the problem, return the changed value back to as it was
  • Repeat above steps until you are positive that you have either too many errors in your script to solve in this method or until you run out of things to change
  • Read the help file again
  • Search the forums with a keyword that is pertinent or related to your script
  • Search the forums again with a new keyword and be sure to check the results beyond just page 1
  • Post on the forums with enough information, so that a person who does not know what you are doing/have done prior to reading your post, will be able to help you. Make sure that your post has evidence that you tried the previous steps
If at any time your question is answered by

The Reply Smoke gave you contained an example that more then explained everything you need to get you program functioning properly, look at pixelsearch in the help file, and perhaps it will give you the info you need to use Smoke_N's example to solve the problem yourself

Edited by Paulie

Share this post


Link to post
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
Sign in to follow this  
Followers 0