Jump to content

Colorclick


 Share

Recommended Posts

Hi

I am trying to make it scan for 2 different pixels and if found then click it, I want it to go on forever, i think i will put in a hotkey later on, just not sure where to go from here:

While 1
   $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeFbff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xef4a3c)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeFbff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xef4a3c)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeFbff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xef4a3c)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeFbff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xef4a3c)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
    EndIf
    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, 0xeeFbff)
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
        ContinueLoop
Link to comment
Share on other sites

Is there something wrong with your script?

For starters I would like to have it much shorter.

And it also gives off an error when i run it.

I probably want to add this code too: HotKeySet("{F5}", "_StopIt")

HotKeySet("{F5}")

But right now i need to figure out how to make it shorter and tidier.

Link to comment
Share on other sites

For starters I would like to have it much shorter.

And it also gives off an error when i run it.

I probably want to add this code too: HotKeySet("{F5}", "_StopIt")

HotKeySet("{F5}")

But right now i need to figure out how to make it shorter and tidier.

So you come to this forum after not even attempting to learn to code....You have very very obvious mistakes in your code. The code obviously isn't yours and the code is likely for something game related....so why are we to help you?

Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff]
While 1
    for $i=0 to (UBound($colourarray)-1)
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        ContinueLoop
                    EndIf
    Next
WEnd
Link to comment
Share on other sites

So you come to this forum after not even attempting to learn to code....You have very very obvious mistakes in your code. The code obviously isn't yours and the code is likely for something game related....so why are we to help you?

Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff]
While 1
    for $i=0 to (UBound($colourarray)-1)
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        ContinueLoop
                    EndIf
    Next
WEnd

Works like a charm.

Is there any way to make it not press in the same area for 3 seconds after left click?

I tried adding a sleep command but that was not the result that I am looking for. maybe creating an imaginary 20x20 box or something is the answer?

Edit: Small interface and a hotkey:

; ; A simple custom messagebox that uses the MessageLoop mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $GoID , $ExitID, $msg

    GUICreate("Custom Msgbox", 210, 80)

    GUICtrlCreateLabel("Please click a button!", 10, 10)
    $GoID = GUICtrlCreateButton("Go", 10, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()  ; display the GUI

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $GoID
                HotKeySet("{F5}", "_StopIt")
                Local $colourarray[9]=[0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041]
While 1
    for $i=0 to (UBound($colourarray)-1)
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        ContinueLoop
                    EndIf
    Next
Wend
            HotKeySet("{F5}")
            Case $msg = $ExitID
                MsgBox(0, "You clicked on", "Exit")
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "You clicked on", "Close")
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
EndFunc   ;==>_Main
Edited by snoopy
Link to comment
Share on other sites

; A simple custom messagebox that uses the MessageLoop mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $GoID , $ExitID, $msg

    GUICreate("Custom Msgbox", 210, 80)

    GUICtrlCreateLabel("Please click a button!", 10, 10)
    $GoID = GUICtrlCreateButton("Go", 10, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()  ; display the GUI
    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $GoID
                HotKeySet("{F5}", "_StopIt")
                Local $colourarray[9]=[0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041]
                While 1
                    for $i=0 to (UBound($colourarray)-1)
                    $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        ContinueLoop
                    EndIf
    Next
Wend
            Case $msg = $ExitID
                MsgBox(0, "You clicked on", "Exit")
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "You clicked on", "Close")
                HotKeySet("{F5}")
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
EndFunc   ;==>_Main

Edited by snoopy
Link to comment
Share on other sites

I suppose 3 seconds has to be 3 seconds every time...

I'm not satisfied with this solution because this is not the case. But I believe you need to play with adlibregister or put a sleep in your main loop and count the times looped through to get to 3 seconds.

Good luck

Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff]
local $tempaddress[1][4]=[[0,0,0,0]]
Global $itsago=10
AdlibRegister("waiting",3000)
While 1
    for $i=0 to (UBound($colourarray)-1)
        
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 and $itsago=10 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        $itsago=0
                        
                        ContinueLoop
                    EndIf
                Next
    WEnd
            
Func waiting()
    if $itsago=10 then Return
if $itsago=0 then
    $itsago=1
    ToolTip("waiting")
Else
$itsago=10

    ToolTip("")
EndIf
ConsoleWrite($itsago&@crlf)
EndFunc
Edited by picea892
Link to comment
Share on other sites

I suppose 3 seconds has to be 3 seconds every time...

I'm not satisfied with this solution because this is not the case. But I believe you need to play with adlibregister or put a sleep in your main loop and count the times looped through to get to 3 seconds.

Good luck

Local $colourarray[9]=[0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff,0xef4a3c,0xeeFbff]
local $tempaddress[1][4]=[[0,0,0,0]]
Global $itsago=10
AdlibRegister("waiting",3000)
While 1
    for $i=0 to (UBound($colourarray)-1)
        
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 and $itsago=10 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        $itsago=0
                        
                        ContinueLoop
                    EndIf
                Next
    WEnd
            
Func waiting()
    if $itsago=10 then Return
if $itsago=0 then
    $itsago=1
    ToolTip("waiting")
Else
$itsago=10

    ToolTip("")
EndIf
ConsoleWrite($itsago&@crlf)
EndFunc

I am sorry I was being very vague, What I wanted to say was that it will not hit in that specific area for 3 seconds (maybe anywhere in around 20x20 pixels ) and rather keep scanning for the other pixels.

Say it found 0xeeFbff, then it would create a 20x20 box in around that pixel and that box would last there for 1 or 2 seconds , meanwhile it would still be scanning for the other pixels including the one it just found.

Why I am saying a box is because it tends to waste alot of clicks on 1 pixel rather then move on to the others after pressing it once, so a box would cover that pixel and will let the script to move on , or is there any better solution?

Edited by snoopy
Link to comment
Share on other sites

You can use timeinit() and timediff()

Anyway if you use scite use the tidy tool, becasue it is confusing look at your script.

About the variable, look the consoleoutput from the scite.. it tells you the line and the character position of where the error is.

Link to comment
Share on other sites

You can use timeinit() and timediff()

Anyway if you use scite use the tidy tool, becasue it is confusing look at your script.

About the variable, look the consoleoutput from the scite.. it tells you the line and the character position of where the error is.

I cannot find that tool under tools , am I looking in the wrong place?

also

; A simple custom messagebox that uses the MessageLoop mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $Credits , $GoID , $ExitID, $msg

    GUICreate("Custom Msgbox", 210, 80)

    GUICtrlCreateLabel("Please click a button!", 10, 10)
    $GoID = GUICtrlCreateButton("Go", 10, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)
    $CreditsID = GUICtrlCreateButton("Exit", 350, 50, 50, 20)
    GUISetState()  ; display the GUI
    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $GoID
                HotKeySet("{F5}", "_StopIt")
                Local $colourarray[9]=[0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041,0xe6b77c,0x613582,0xed8041]
local $tempaddress[1][4]=[[0,0,0,0]]
Global $itsago=10
AdlibRegister("waiting",50)
While 1
    for $i=0 to (UBound($colourarray)-1)
        
        $pixelSearch = PixelSearch(57, 45, @DesktopWidth, @DesktopHeight, $colourarray[$i])
                    If IsArray($pixelSearch) = 1 and $itsago=10 Then
                        MouseClick("left", $pixelSearch[0], $pixelSearch[1], 1, 0)
                        $itsago=0
                        
                        ContinueLoop
                    EndIf
                Next
            WEnd
            
            
Func waiting()
    if $itsago=10 then Return
if $itsago=0 then
    $itsago=1
    ToolTip("waiting")
Else
$itsago=10

    ToolTip("")
EndIf
ConsoleWrite($itsago&@crlf)
EndFunc
HotKeySet("{F5}")
            Case $msg = $ExitID
                MsgBox(0, "You clicked on", "Exit")
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "You clicked on", "Close")
                
            Case $Credits = $msg
                MsgBox(64, "Credits", "Snoopy")
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
EndFunc   ;==>_Main

It says that ""Func" statement has no matching "EndFunc".:" , I assume that it is talking about this line:

Func waiting()
    if $itsago=10 then Return
if $itsago=0 then
    $itsago=1
    ToolTip("waiting")
Else
$itsago=10

    ToolTip("")
EndIf
ConsoleWrite($itsago&@crlf)
EndFunc

But I clearly see endFunc at the end.. Why do I still get an error?

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