Jump to content

Moving to pixels


Guest Staircase
 Share

Recommended Posts

Guest Staircase

I know how to locate a pixel on the screen, but i want to have it so when it locates it it can move left or right dependin where the pixel is. then i want it to click ctrl to attack when it is next tto the pixel. i have looked in the help file but can find it. But since i am a NOOB i may have overlooked it. can any1 help me with this? ANY help is appreciated.

Link to comment
Share on other sites

Guest Staircase

Look at the helpfile for these functions:

PixelSearch()

PixelGetColor()

MouseMove()

MouseClick()

I'd tell you exactly how to do it, but I'm beginngin to agree with the other forum members. It is best to figure it out on your own (with a little guidance).

-CMR

<{POST_SNAPBACK}>

WHich 1 is specificly for moving twords the pixel. and how do i do it? Im sorry im so nooby but i wanna lean this and ive already leaned how to macro button clicks or mouse clicks.
Link to comment
Share on other sites

Alright I'll explain it, but I won't give you that much code:

Let's say on our screen we have a green box somewhere. We know it usually is in the upper left quadrant. So, we use PixelSearch() to search that area of the screen for the color green. Now, if it is found, PixelSearch will return the exact position it found the color so we have to save that into a varaible. Then we can use MouseClick() to click on that position.

For example:

;Let's say we are at 800x600 resolution, Let's search the upper left quadrant.

;Variable for position           The function to find the color:
$Position_of_Green =            PixelSearch(0,0  400,300, 0x00FF00,10,1)

If Not @error Then
        MouseClick("left",$Position_of_Green[0],$Position_of_Green[1])
EndIf

Ok, the function PixelSearch() returns a two element array containing the position it found the color. So, it changes $Position_of_Green into $Position_of_Green[2]. The helpfile for PixelSearch() cna be confusing, so just think of the first 4 parameters as a rectangle. The color can be either Hex or decimal format (See the helpfile on ColorMode option). The shade is how many variations of that color it will look for. The step is how many pixels it searches in a row. A step of 1 (one) will search every pixel in our rectangle. A step of 2 will search every other pixel, and so on. The size of your rectangle, the number of shades, and the step all affect how fast it will search. For the fastest search, narrow your color shades down to 5-10 and your size down to 20x20. On my system, it takes 1.5 seconds to search a 300x300 area with a step of one and searching 10 shades. If all that has confused you more, look at this:

PixelSearch($Top_X,$Top_Y, $Bottom_X, $Bottom_Y, $Color, $Shade, $Step)

Now, let's say you know the exact position that color is going to show up and is always the same color (Let's say it's a blue-ish green). You can use the PixelGetColor() function like so:

$Color = PixelGetColor($Position_X,$Position_Y)

If (Hex($Color) == 0x00FF12) Then
        MouseClick("left",$Position_X,$Position_Y)
EndIf

PixelGetColor() returns a decimal value, so I convert that to Hexadecimal and then see if it is the same as our blue-ish green (0x00FF12). This is much much faster than pixel search, but you don't always have that option (especially since most games have alot of shadowing and special effects).

Hope that clears things up for you.

-CMR

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...