Jump to content

Wont stop...


Calster
 Share

Recommended Posts

When i run my Colour Clicker script it clicks fine and everything, but when i want it to stop clicking (but not exit the script) so i can change the settings.

anyway i press my hotkey to stop the clicking (ESC) but it keeps on clicking.... Well i hope you can help me.... Heres my script

The function to stop the clicking is at the bottom in the $msg = $Start case...

#include <GUIConstants.au3>
GUICreate("Color Clicker")
GUISetState(@SW_SHOW)
$menu1 = GUICtrlCreateMenu("Help")
$Menu11 = GUICtrlCreateMenuItem("Help", $menu1)

HotKeySet("{ESC}", "Close")
HotKeySet("{F9}", "GetCol")
HotKeySet("{F10}", "GetCol1")
HotKeySet("{F11}", "GetCol2")
HotKeySet("{F8}", "start")
HotKeySet("{F1}", "TL")
HotKeySet("{F2}", "BR")

$Start = GUICtrlCreateButton("Start", 0, 0, 100, 25)
; Coords
GUICtrlCreateLabel("Coordinates:", 0, 30)
GUICtrlCreateLabel("Top:", 0, 80)
GUICtrlCreateLabel("Left:", 0, 50)
GUICtrlCreateLabel("Bottom:", 0, 140)
GUICtrlCreateLabel("Right:", 0, 110)
; Inputs
$Top = GUICtrlCreateInput("", 50, 80, 70, 20)
$Left = GUICtrlCreateInput("", 50, 50)
$Bottom = GUICtrlCreateInput("", 50, 140)
$Right = GUICtrlCreateInput("", 50, 110)

; Colour
GUICtrlCreateLabel("Colour 1:", 0, 190)
GUICtrlCreateLabel("Colour 2:", 130, 190)
GUICtrlCreateLabel("Colour 3:", 260, 190)
; Input
$Colour = GUICtrlCreateInput("", 50, 190, 70)
$Colour2 = GUICtrlCreateInput("", 180, 190, 70)
$Colour3 = GUICtrlCreateInput("", 310, 190, 70)

GUICtrlCreateLabel("Delay between clicks:", 0, 230)
$Delay = GUICtrlCreateInput("0", 110, 230, 70, 20)
GUICtrlCreateLabel("(In Miliseconds)", 180, 230)

GUICtrlCreateLabel("Made By Callum Scaife (AKA Calster)", 110, 350)

Func start()
    $msg = $Start
EndFunc   ;==>start

Func Close ()
    Exit
EndFunc   ;==>Close

Func TL()
    GUICtrlSetData($Left, $Pos[0])
    GUICtrlSetData($Top, $Pos[1])
EndFunc   ;==>TL

Func BR()
    GUICtrlSetData($Right, $Pos[0])
    GUICtrlSetData($Bottom, $Pos[1])
EndFunc   ;==>BR

Func GetCol()
    GUICtrlSetColor($Colour, $Col1)
    GUICtrlSetData($Colour, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour, GUICtrlRead($Colour))
EndFunc   ;==>GetCol

Func GetCol1()
    GUICtrlSetColor($Colour2, $Col1)
    GUICtrlSetData($Colour2, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour2, GUICtrlRead($Colour2))
EndFunc   ;==>GetCol1

Func GetCol2()
    GUICtrlSetColor($Colour3, $Col1)
    GUICtrlSetData($Colour3, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour3, GUICtrlRead($Colour3))
EndFunc   ;==>GetCol2


While 1
    Dim $Colours[3]
    $Colours[0] = GUICtrlRead($Colour)
    $Colours[1] = GUICtrlRead($Colour2)
    $Colours[2] = GUICtrlRead($Colour3)
    $Pos = MouseGetPos()
    $Col1 = PixelGetColor($Pos[0], $Pos[1])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start
            While 1
                For $C = 0 To 2
                    $Click = PixelSearch(GUICtrlRead($Left), GUICtrlRead($Top), GUICtrlRead($Right), GUICtrlRead($Bottom), $Colours[$C], 10)
                    If Not @error Then
                        MouseClick("Left", $Click[0], $Click[1], 1, 1)
                        Sleep(GUICtrlRead($Delay))
                    EndIf
                Next
            WEnd
        Case $msg = $Menu11
            Run("Help.exe")
    EndSelect
WEnd

Thank you all in advance, this is probably a newbie question... but since its from a newbie thats ok right? <_<

Edited by Calster

Calster - User and lover of AutoIt !

Link to comment
Share on other sites

In my script at the top, it shoulb be that the func Close() is in the while loop at the bottom (Case $msg = $Start) and instead of exit it should be ExitLoop ... Sorry cant edit the original post.

Calster - User and lover of AutoIt !

Link to comment
Share on other sites

In my script at the top, it shoulb be that the func Close() is in the while loop at the bottom (Case $msg = $Start) and instead of exit it should be ExitLoop ... Sorry cant edit the original post.

Like this?

#include <GUIConstants.au3>
Opt("GUICloseOnESC",0)
GUICreate("Color Clicker")
GUISetState(@SW_SHOW)
$menu1 = GUICtrlCreateMenu("Help")
$Menu11 = GUICtrlCreateMenuItem("Help", $menu1)
$Stop=False

HotKeySet("{ESC}", "Close")
HotKeySet("{F9}", "GetCol")
HotKeySet("{F10}", "GetCol1")
HotKeySet("{F11}", "GetCol2")
HotKeySet("{F8}", "start")
HotKeySet("{F1}", "TL")
HotKeySet("{F2}", "BR")

$Start = GUICtrlCreateButton("Start", 0, 0, 100, 25)
; Coords
GUICtrlCreateLabel("Coordinates:", 0, 30)
GUICtrlCreateLabel("Top:", 0, 80)
GUICtrlCreateLabel("Left:", 0, 50)
GUICtrlCreateLabel("Bottom:", 0, 140)
GUICtrlCreateLabel("Right:", 0, 110)
; Inputs
$Top = GUICtrlCreateInput("", 50, 80, 70, 20)
$Left = GUICtrlCreateInput("", 50, 50)
$Bottom = GUICtrlCreateInput("", 50, 140)
$Right = GUICtrlCreateInput("", 50, 110)

; Colour
GUICtrlCreateLabel("Colour 1:", 0, 190)
GUICtrlCreateLabel("Colour 2:", 130, 190)
GUICtrlCreateLabel("Colour 3:", 260, 190)
; Input
$Colour = GUICtrlCreateInput("", 50, 190, 70)
$Colour2 = GUICtrlCreateInput("", 180, 190, 70)
$Colour3 = GUICtrlCreateInput("", 310, 190, 70)

GUICtrlCreateLabel("Delay between clicks:", 0, 230)
$Delay = GUICtrlCreateInput("0", 110, 230, 70, 20)
GUICtrlCreateLabel("(In Miliseconds)", 180, 230)

GUICtrlCreateLabel("Made By Callum Scaife (AKA Calster)", 110, 350)

While Not $Stop
    Dim $Colours[3]
    $Colours[0] = GUICtrlRead($Colour)
    $Colours[1] = GUICtrlRead($Colour2)
    $Colours[2] = GUICtrlRead($Colour3)
    $Pos = MouseGetPos()
    $Col1 = PixelGetColor($Pos[0], $Pos[1])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start
            While 1
                For $C = 0 To 2
                    $Click = PixelSearch(GUICtrlRead($Left), GUICtrlRead($Top), GUICtrlRead($Right), GUICtrlRead($Bottom), $Colours[$C], 10)
                    If Not @error Then
                        MouseClick("Left", $Click[0], $Click[1], 1, 1)
                        Sleep(GUICtrlRead($Delay))
                    EndIf
                Next
                If $Stop then ExitLoop
            WEnd
        Case $msg = $Menu11
            Run("Help.exe")
    EndSelect
WEnd


Func start()
    $msg = $Start
EndFunc   ;==>start

Func Close ()
    $Stop=True
EndFunc   ;==>Close

Func TL()
    GUICtrlSetData($Left, $Pos[0])
    GUICtrlSetData($Top, $Pos[1])
EndFunc   ;==>TL

Func BR()
    GUICtrlSetData($Right, $Pos[0])
    GUICtrlSetData($Bottom, $Pos[1])
EndFunc   ;==>BR

Func GetCol()
    GUICtrlSetColor($Colour, $Col1)
    GUICtrlSetData($Colour, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour, GUICtrlRead($Colour))
EndFunc   ;==>GetCol

Func GetCol1()
    GUICtrlSetColor($Colour2, $Col1)
    GUICtrlSetData($Colour2, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour2, GUICtrlRead($Colour2))
EndFunc   ;==>GetCol1

Func GetCol2()
    GUICtrlSetColor($Colour3, $Col1)
    GUICtrlSetData($Colour3, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour3, GUICtrlRead($Colour3))
EndFunc   ;==>GetCol2
Link to comment
Share on other sites

No like this:

#include <GUIConstants.au3>
Opt("GUICloseOnESC",0)
GUICreate("Color Clicker")
GUISetState(@SW_SHOW)
$menu1 = GUICtrlCreateMenu("Help")
$Menu11 = GUICtrlCreateMenuItem("Help", $menu1)
$Stop=False
 
HotKeySet("{ESC}", "Close")
HotKeySet("{F9}", "GetCol")
HotKeySet("{F10}", "GetCol1")
HotKeySet("{F11}", "GetCol2")
HotKeySet("{F8}", "start")
HotKeySet("{F1}", "TL")
HotKeySet("{F2}", "BR")

$Start = GUICtrlCreateButton("Start", 0, 0, 100, 25)
; Coords
GUICtrlCreateLabel("Coordinates:", 0, 30)
GUICtrlCreateLabel("Top:", 0, 80)
GUICtrlCreateLabel("Left:", 0, 50)
GUICtrlCreateLabel("Bottom:", 0, 140)
GUICtrlCreateLabel("Right:", 0, 110)
; Inputs
$Top = GUICtrlCreateInput("", 50, 80, 70, 20)
$Left = GUICtrlCreateInput("", 50, 50)
$Bottom = GUICtrlCreateInput("", 50, 140)
$Right = GUICtrlCreateInput("", 50, 110)

; Colour
GUICtrlCreateLabel("Colour 1:", 0, 190)
GUICtrlCreateLabel("Colour 2:", 130, 190)
GUICtrlCreateLabel("Colour 3:", 260, 190)
; Input
$Colour = GUICtrlCreateInput("", 50, 190, 70)
$Colour2 = GUICtrlCreateInput("", 180, 190, 70)
$Colour3 = GUICtrlCreateInput("", 310, 190, 70)

GUICtrlCreateLabel("Delay between clicks:", 0, 230)
$Delay = GUICtrlCreateInput("0", 110, 230, 70, 20)
GUICtrlCreateLabel("(In Miliseconds)", 180, 230)

GUICtrlCreateLabel("Made By Callum Scaife (AKA Calster)", 110, 350)

While Not $Stop
    Dim $Colours[3]
    $Colours[0] = GUICtrlRead($Colour)
    $Colours[1] = GUICtrlRead($Colour2)
    $Colours[2] = GUICtrlRead($Colour3)
    $Pos = MouseGetPos()
    $Col1 = PixelGetColor($Pos[0], $Pos[1])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start
            While 1
                For $C = 0 To 2
                    Func Close ()
                            $Stop=True
                    EndFunc   ;==>Close
                    $Click = PixelSearch(GUICtrlRead($Left), GUICtrlRead($Top), GUICtrlRead($Right), GUICtrlRead($Bottom), $Colours[$C], 10)
                    If Not @error Then
                        MouseClick("Left", $Click[0], $Click[1], 1, 1)
                        Sleep(GUICtrlRead($Delay))
                    EndIf
                Next
                If $Stop then ExitLoop
            WEnd
        Case $msg = $Menu11
            Run("Help.exe")
    EndSelect
WEnd
Func start()
    $msg = $Start
EndFunc   ;==>start

Func TL()
    GUICtrlSetData($Left, $Pos[0])
    GUICtrlSetData($Top, $Pos[1])
EndFunc   ;==>TL

Func BR()
    GUICtrlSetData($Right, $Pos[0])
    GUICtrlSetData($Bottom, $Pos[1])
EndFunc   ;==>BR

Func GetCol()
    GUICtrlSetColor($Colour, $Col1)
    GUICtrlSetData($Colour, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour, GUICtrlRead($Colour))
EndFunc   ;==>GetCol

Func GetCol1()
    GUICtrlSetColor($Colour2, $Col1)
    GUICtrlSetData($Colour2, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour2, GUICtrlRead($Colour2))
EndFunc   ;==>GetCol1

Func GetCol2()
    GUICtrlSetColor($Colour3, $Col1)
    GUICtrlSetData($Colour3, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour3, GUICtrlRead($Colour3))
EndFunc   ;==>GetCol2

As i say sorry for all of this confusion and i hope somebody can help solve my problem... which is that when i press ESC the script keeps on clicking.

~Thanks - Calster

Calster - User and lover of AutoIt !

Link to comment
Share on other sites

You want it to stop clicking but not quit the program?

#include <GUIConstants.au3>
Opt("GUICloseOnESC",0)
GUICreate("Color Clicker")
GUISetState(@SW_SHOW)
$menu1 = GUICtrlCreateMenu("Help")
$Menu11 = GUICtrlCreateMenuItem("Help", $menu1)

HotKeySet("{ESC}", "Close")
HotKeySet("{F9}", "GetCol")
HotKeySet("{F10}", "GetCol1")
HotKeySet("{F11}", "GetCol2")
HotKeySet("{F8}", "start")
HotKeySet("{F1}", "TL")
HotKeySet("{F2}", "BR")

$Start = GUICtrlCreateButton("Start", 0, 0, 100, 25)
; Coords
GUICtrlCreateLabel("Coordinates:", 0, 30)
GUICtrlCreateLabel("Top:", 0, 80)
GUICtrlCreateLabel("Left:", 0, 50)
GUICtrlCreateLabel("Bottom:", 0, 140)
GUICtrlCreateLabel("Right:", 0, 110)
; Inputs
$Top = GUICtrlCreateInput("", 50, 80, 70, 20)
$Left = GUICtrlCreateInput("", 50, 50)
$Bottom = GUICtrlCreateInput("", 50, 140)
$Right = GUICtrlCreateInput("", 50, 110)

; Colour
GUICtrlCreateLabel("Colour 1:", 0, 190)
GUICtrlCreateLabel("Colour 2:", 130, 190)
GUICtrlCreateLabel("Colour 3:", 260, 190)
; Input
$Colour = GUICtrlCreateInput("", 50, 190, 70)
$Colour2 = GUICtrlCreateInput("", 180, 190, 70)
$Colour3 = GUICtrlCreateInput("", 310, 190, 70)

GUICtrlCreateLabel("Delay between clicks:", 0, 230)
$Delay = GUICtrlCreateInput("0", 110, 230, 70, 20)
GUICtrlCreateLabel("(In Miliseconds)", 180, 230)

GUICtrlCreateLabel("Made By Callum Scaife (AKA Calster)", 110, 350)

While 1
    Global $Stop=False
    Dim $Colours[3]
    $Colours[0] = GUICtrlRead($Colour)
    $Colours[1] = GUICtrlRead($Colour2)
    $Colours[2] = GUICtrlRead($Colour3)
    $Pos = MouseGetPos()
    $Col1 = PixelGetColor($Pos[0], $Pos[1])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start
            While Not $Stop
                For $C = 0 To 2
                    $Click = PixelSearch(GUICtrlRead($Left), GUICtrlRead($Top), GUICtrlRead($Right), GUICtrlRead($Bottom), $Colours[$C], 10)
                    If Not @error Then
                        MouseClick("Left", $Click[0], $Click[1], 1, 1)
                        Sleep(GUICtrlRead($Delay))
                    EndIf
                Next
                If $Stop then ExitLoop
            WEnd
        Case $msg = $Menu11
            Run("Help.exe")
    EndSelect
WEnd
Func start()
    $msg = $Start
EndFunc   ;==>start
Func Close ()
        $Stop=True
EndFunc   ;==>Close

Func TL()
    GUICtrlSetData($Left, $Pos[0])
    GUICtrlSetData($Top, $Pos[1])
EndFunc   ;==>TL

Func BR()
    GUICtrlSetData($Right, $Pos[0])
    GUICtrlSetData($Bottom, $Pos[1])
EndFunc   ;==>BR

Func GetCol()
    GUICtrlSetColor($Colour, $Col1)
    GUICtrlSetData($Colour, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour, GUICtrlRead($Colour))
EndFunc   ;==>GetCol

Func GetCol1()
    GUICtrlSetColor($Colour2, $Col1)
    GUICtrlSetData($Colour2, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour2, GUICtrlRead($Colour2))
EndFunc   ;==>GetCol1

Func GetCol2()
    GUICtrlSetColor($Colour3, $Col1)
    GUICtrlSetData($Colour3, $Col1)
    Sleep(100)
    GUICtrlSetBkColor($Colour3, GUICtrlRead($Colour3))
EndFunc   ;==>GetCol2
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...