Jump to content

Pixel Search - Help with script please


Recommended Posts

Ok, so i need some help. I need to figure out how to get this to work

If MouseClick("middle") Then ;Step1 Click Middle Mouse Key

;

Dim $cordinates = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,0x2B3033) ;Step 2 Search for pixel

;

MouseClick( "left",$cordinates[0],$cordinates[1],1,0) ;Step 3 Found it!! and click once!

;

If @error Then EndIf ;Step4 If i didnt find it stop and wait for middle key

so if anyone could help me that would be great :mellow: im really trying here it seems nothing will work.

Link to comment
Share on other sites

A few things.

MouseClick clicks the mouse. You want a function more like _IsPressed(4) or something.

EndIf ends a block. So you want ContinueLoop.

Try this:

#include<Misc.au3>

While 1
    If _IsPressed(4) Then
        Local $cordinates = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,0x2B3033)
        If @error Then ContinueLoop

        MouseClick( "left",$cordinates[0],$cordinates[1],1,0)
    EndIf

    Sleep(10)
WEnd

Mat

Link to comment
Share on other sites

wow i feel stupid i didnt think of that and i had the wrong end statement without realizing it thank you very much

EDIT: is there a way to search only around a small radius from the mouse or even more then one color before clicking?

Edited by northlight
Link to comment
Share on other sites

wow i feel stupid i didnt think of that and i had the wrong end statement without realizing it thank you very much

EDIT: is there a way to search only around a small radius from the mouse or even more then one color before clicking?

Well... Yes it is.

MouseGetPos() returns the position of the mouse in the same way as PixelSearch does.

If you want an actual radius as in circles... Thats a lot of maths and not advised. You're better off searching a square.

Local $iRadius = 50

Local $aMousePos = MouseGetPos()
Local $aPixel = PixelSearch($aMousePos[0] - $iRadius, $aMousePos[1] - $iRadius, $aMousePos[0] + $iRadius, $aMousePos[1] + $iRadius, 0x2B3033)

More than one is... more than 1 PixelSearch :mellow:

Edited by Mat
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...