Jump to content

Pixel Search around a radius of the mouse


Recommended Posts

I obviously now how to pixel search:

PixelSearch( 0, 0, 1000, 585, $color, 3, 5 )

Buy I dont want the coords to search for to be 0, 0, 1000, 585 as in this example,

I want it to be a radius of say 30 (it will b user defined, but I know how to do that part)

While 1
    If $game = 1 Then
        PixelSearch( 0, 0, 1000, 585, $color, 3, 5 )
            If IsArray($coord) = 1 Then
                MouseMove( $coord[0], $coord[1], 0)
            EndIf
        Sleep(500)
    EndIf
WEnd

Thank you very much for any help and time you give!

Link to comment
Share on other sites

see: MouseGetPos In your help file,

Then just use that and some math to get the four corners of your search.

Alright, I think that helped...

While 1
    If $game = 1 Then
            $pos = MouseGetPos()
            $coord = PixelSearch( $pos[0]+30, $pos[1]+30, $pos[0]-30, $pos[1]-30, $color, 3, 5 )
            If IsArray($coord) = 1 Then
                MouseMove( $coord[0], $coord[1], 0)
            EndIf
        Sleep(500)
    EndIf
WEnd

This looks a bit better to me, But even so, this will produce a square around the cursor, if it would even do that ;P, I would prefer a circle

Edited by bigassmuffin
Link to comment
Share on other sites

Alright, I think that helped...

While 1
    If $game = 1 Then
            $pos = MouseGetPos()
            $coord = PixelSearch( $pos[0]+30, $pos[1]+30, $pos[0]-30, $pos[1]-30, $color, 3, 5 )
            If IsArray($coord) = 1 Then
                MouseMove( $coord[0], $coord[1], 0)
            EndIf
        Sleep(500)
    EndIf
WEnd

This looks a bit better to me, But even so, this will produce a square around the cursor, if it would even do that ;P, I would prefer a circle

Your pluses and minuses are incorrect?

The below eliminates the 4 outside corners. Still leaves little pieces of included area which could be eliminated with further extraction of squares inside ellipses. Not sure why you have to have a circle but this should bring you a little closer.

If you take your 30 as the radius.

$r = 30

Then inside square radius = $r ( INT(($r ^2+$r ^2)^(1/2))- $r) :rounded to a whole number = 18

So first check out inside square

$coord = PixelSearch( $pos[0]-18, $pos[1]-18, $pos[0]+18, $pos[1]+18, $color, 3, 5 )

Then check the four outside rectangles (long way you could create a loop for the whole thing)

(left, top, right and bottom)

$coord = PixelSearch( $pos[0]-30, $pos[1]-18, $pos[0]-18, $pos[1]+18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]-18, $pos[1]-30, $pos[0]+18, $pos[1]-18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]+18, $pos[1]-18, $pos[0]+30, $pos[1]+18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]-18, $pos[1]+18, $pos[0]+18, $pos[1]+30, $color, 3, 5 )

Not sure if this helps and I have not tested it.

Edited by 1905russell
Link to comment
Share on other sites

If you take your 30 as the radius.

$r = 30

Then inside square radius = $r ( INT(($r ^2+$r ^2)^(1/2))- $r) :rounded to a whole number = 18

So first check out inside square

$coord = PixelSearch( $pos[0]-18, $pos[1]-18, $pos[0]+18, $pos[1]+18, $color, 3, 5 )

Then check the four outside rectangles (long way you could create a loop for the whole thing)

(left, top, right and bottom)

$coord = PixelSearch( $pos[0]-30, $pos[1]-18, $pos[0]-18, $pos[1]+18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]-18, $pos[1]-30, $pos[0]+18, $pos[1]-18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]+18, $pos[1]-18, $pos[0]+30, $pos[1]+18, $color, 3, 5 )

$coord = PixelSearch( $pos[0]-18, $pos[1]+18, $pos[0]+18, $pos[1]+30, $color, 3, 5 )

Not sure if this helps and I have not tested it.

Thank you for inputing all your time in this, however a square will still be good enough, however, doi you think the script i posted will work(the script u quoted)

Link to comment
Share on other sites

Thank you for inputing all your time in this, however a square will still be good enough, however, doi you think the script i posted will work(the script u quoted)

Wow you were fast

I edited my post to tell you that your + and - should be reversed.

I enjoyed trying to remember my rusty trigonometry.

If you want to be more accurate in your search, leave out the shade and the step.

If you really wanted an accurate circle you would need to PixelSearch each row individualy with a calculated start and stop position for each row. Its possible I guess.

Edited by 1905russell
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...