Jump to content

toggle mouse is color autoClick


Recommended Posts

Posted (edited)

versatile and quick method to click on color.

pause key pauses and resets color. the color that is mouse when activated is clicked while that color.

end quits the script

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.16.0
 Author:         #IAmMajor

 Script Function:
    autoClick while mouse color is on toggle.

#ce ----------------------------------------------------------------------------

$color = getColor()
$pause = True
HotKeySet("{end}", "stop")
HotKeySet("{pause}", "pause")

Func pause()
    If ($pause) Then
        $color = getColor()
        $pause = False
    Else
        $pause = True
    EndIf
EndFunc   ;==>pause

Func stop()
    Exit
EndFunc   ;==>stop

Func getColor()
    Local $aPos = MouseGetPos()
    Return PixelGetColor($aPos[0], $aPos[1])
EndFunc   ;==>getColor

While 1
    If (Not $pause) Then
        If (getColor() == $color) Then
            MouseClick("Primary")
        Else
            Sleep(10)
        EndIf
    Else
        Sleep(1000)
    EndIf
WEnd

 

Also an offset version, i know some times  color is as the mouse.
Subtacting mouse position by defined as offset=5

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.16.0
 Author:         #IAmMajor

 Script Function:
    autoClick while mouse color is on toggle.

#ce ----------------------------------------------------------------------------

$offset = 5
$color = getColor()
$pause = True
HotKeySet("{end}", "stop")
HotKeySet("{pause}", "pause")

Func pause()
    If ($pause) Then
        $color = getColor()
        $pause = False
    Else
        $pause = True
    EndIf
EndFunc   ;==>pause

Func stop()
    Exit
EndFunc   ;==>stop

Func getColor()
    Local $aPos = MouseGetPos()
    Return PixelGetColor($aPos[0]-$offset, $aPos[1]-$offset)
EndFunc   ;==>getColor

While 1
    If (Not $pause) Then
        If (getColor() == $color) Then
            MouseClick("Primary")
        Else
            Sleep(10)
        EndIf
    Else
        Sleep(1000)
    EndIf
WEnd

 

Edited by major_lee
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...