Jump to content

PixelSearch question


Recommended Posts

Ok, so I have this function, whilst it is running the commands, I need it to also be searching for a certain pixel,if it is there it is to click on that location once,then continue running the previous instruction.

This is what I have so far, any pointers will be greatly appreciated!

Func Laiz2()
    While 1
        If WinExists("Adobe Flash Player") Then
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
else
                        Harvest()
            Sleep(360000)
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
else
            Plow()
            Sleep(360000)
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
else
            Plant()
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
else
            Sleep(7800000)
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
        Else
            Login()
            Sleep(10000)
            Harvest()
            Sleep(360000)
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
            Plow()
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
            Sleep(360000)
            Plant()
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
            Sleep(7800000)
            $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A) 
                        If Not @error Then
                        MouseClick("Left",$coord[0],$coord[1],1,0)
        EndIf
    WEnd
EndFunc   ;==>Laiz2
Edited by BitByteBit
Link to comment
Share on other sites

Good point.

I'm still having trouble with this, I changed the code, however now it still doesn't work and i don't know why!!!

Func Check ()
                    $coord = PixelSearch( 142, 46, 900, 600, 0xC3463A)
                    If Not @error Then
                    MouseClick("Left",$coord[0],$coord[1],1,0)
                EndIf
            EndFunc


Func Check2 ()
                    $coord2 = PixelSearch( 476,538,552,566, 0x94BC41)
                    If Not @error Then
                    MouseClick("Left",$coord2[0],$coord2[1],1,0)
                EndIf
    EndFunc


Func Laiz3()
Sleep(4248000)
    While 1
Check()
Check2()
            Harvest()
Check()
Check2()
            Sleep(280000)
Check()
Check2()
            Plow()
Check()
Check2()
            Sleep(280000)
Check()
Check2()
            Plant()
            Sleep(280000)
Check()
Check2()
            sleep(7800000)
WEnd
EndFunc
Link to comment
Share on other sites

how about this, your H Plant Plow functions arent even in the code..

Adlibenable("Harvest" 60000)
Adlibenable("Plow", 60000)
Adlibenable("Plant", 60000)
HotKeySet("{PAUSE}", "Escape")

While 1=1
    Call("Check")
    Sleep(150) ; longer delay less cpu
WEnd

Func Check()
    $coord = PixelSearch(142, 46, 900, 600, 0xC3463A)
    If @error Then
        Call("Check2")
    Else
        MouseClick("Left", $coord[0], $coord[1], 1, 0)
    EndIf
EndFunc   ;==>Check


Func Check2()
    $coord2 = PixelSearch(476, 538, 552, 566, 0x94BC41)
    If Not @error Then
        MouseClick("Left", $coord2[0], $coord2[1], 1, 0)
    EndIf
EndFunc   ;==>Check2

Func Escape()
    AdlibDisable()
    Exit
EndFunc   ;==>Escape
Edited by Seagul
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...