Jump to content

pixelseach+mouseclick


botnewb
 Share

Recommended Posts

Hi im new to autoit ive been trying to compile an scipt where i can do pixel search find the color in the designated coordinates and if it is the color do nothing, and if it isnt to mouse click at the coordinates listed below in the code, i also added an function startg and stop but i dont know if i did it right, i compiled most of thise from tips and hints and tried to get it as close as the tutorial in autoit, anywho heres the code can any one shed some light or fix the code make it work possibly.

HotKeySet("{F4}", "ExitProg")

HotKeySet("{F5}", "Start")

HotKeySet("{F6}", "Stop")

Func ExitProg()

Exit 0

EndFunc

Func Start()

While 1

Wend

Func Stop()

Endfunc

MouseClick ( "left" , 300, 12, 1)

sleep (3000)

While 1=1

$pixelsearch= Pixelsearch( 156, 709, 157, 709, "0xDE0408", 1, 2)

If @error = 1 Then

MouseClick("left", 747, 753, 1)

Endif

WEnd

Link to comment
Share on other sites

Maybe something like this:

HotKeySet("{F4}", "ExitProg")
HotKeySet("{F5}", "Start")
HotKeySet("{F6}", "Stop")

Global $running = False

While 1
    If $running Then
;~      MouseClick("left", 300, 12, 1)
;~      Sleep(3000)
        While 1
            $pixelsearch = PixelSearch(156, 709, 157, 709, "0xDE0408", 1, 2)
            If @error = 1 Then
                MouseClick("left", 747, 753, 1)
            Else
                Sleep(10)
            EndIf
            If Not $running Then ExitLoop
        WEnd
    EndIf
    
    Sleep(10)
WEnd

Func ExitProg()
    Exit 0
EndFunc 

Func Start()
    $running = True
EndFunc

Func Stop()
    $running = False
EndFunc
Link to comment
Share on other sites

Or even simpler:

HotKeySet("{F4}", "ExitProg")
HotKeySet("{F5}", "Start")
HotKeySet("{F6}", "Stop")

Global $running = False

While 1
    If $running Then
        $pixelsearch = PixelSearch(156, 709, 157, 709, "0xDE0408", 1, 2)
        If @error = 1 Then
            MouseClick("left", 747, 753, 1)
        EndIf
    EndIf
    
    Sleep(10)
WEnd

Func ExitProg()
    Exit 0
EndFunc 

Func Start()
    $running = True
EndFunc

Func Stop()
    $running = False
EndFunc
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...