Jump to content

After "stop function", Exit button doesn't work


Recommended Posts

Hi, i have a problem. I've made this script below (my first :)) and when I start LeftClick and stop it for example, Exit Button (this red :party:) doesn't work and I must exit program from the tray. Why?

Sorry for my bad english. If someone know answer for my problem, please post it here.

Here is part of the code:

include <GUIConstants.au3>

GUICreate ("Click", 150, 220)
WinMove("Click", "", 10, 760)



GUICtrlCreateLabel ("Functions:", 10, 10)

GUICtrlCreateLabel ("Left Click - F5", 10, 40)
GUICtrlCreateLabel ("Right Click - F6", 10, 60)
GUICtrlCreateLabel ("Stop All - F7", 10, 100)
GUICtrlCreateLabel ("Clicks delay (ms):", 10, 130)

$heal = GUICtrlCreateLabel ("Heal:", 95, 40)
GUICtrlSetFont ($heal, 8)
$heal = GUICtrlCreateInput ("1", 125, 38, 23, 18)

$defence = GUICtrlCreateLabel ("Def:", 95, 60)
GUICtrlSetFont ($defence, 8)
$defence = GUICtrlCreateInput ("2", 125, 58, 23, 18)

$damage = GUICtrlCreateLabel ("Dmg:", 95, 80)
GUICtrlSetFont ($damage, 8)
$damage = GUICtrlCreateInput ("3", 125, 78, 23, 18)

GUICtrlCreateLabel ("Start buff - F11", 10, 80)
GUICtrlCreateLabel ("Buff delay (ms):", 10, 170)


$delay1 = GUICtrlCreateInput ("", 10, 145, 50, 21)
$buffdelay = GUICtrlCreateInput ("", 10, 185, 50, 21)


HotKeySet ("{F5}", "left")
HotKeySet ("{F6}", "right")
HotKeySet ("{F7}", "stop")
HotKeySet ("{F11}", "buff")

Func left ()
While 1
    $var = 1
    While $var = 1
    $delay2 = GUICtrlRead ($delay1)
    Opt("MouseClickDownDelay", 100)
    Opt("MouseClickDelay", $delay2)
    MouseClick ("Left")
    WEnd
Sleep(100)

WEnd
EndFunc

Func right ()
    While 1
        $var = 1
        While $var = 1
        $delay2 = GUICtrlRead ($delay1)
        Opt("MouseClickDownDelay", 100)
        Opt("MouseClickDelay", $delay2)
        MouseClick ("Right")
    WEnd
    Sleep(100)
        
    WEnd
EndFunc

Func stop ()
    While 1 
        $var = 0
    WEnd
EndFunc

GUISetState ()

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd
Link to comment
Share on other sites

All those While loops are preventing the functions from ending, thus preventing other Hotkey functions from being processed.

Try this (untested) :

#include <GUIConstants.au3>

GUICreate("Click", 150, 220)
WinMove("Click", "", 10, 760)

Global Enum $STOP, $LEFT, $RIGHT, $BUFF
Global $iAction

GUICtrlCreateLabel("Functions:", 10, 10)

GUICtrlCreateLabel("Left Click - F5", 10, 40)
GUICtrlCreateLabel("Right Click - F6", 10, 60)
GUICtrlCreateLabel("Stop All - F7", 10, 100)
GUICtrlCreateLabel("Clicks delay (ms):", 10, 130)

$heal = GUICtrlCreateLabel("Heal:", 95, 40)
GUICtrlSetFont($heal, 8)
$heal = GUICtrlCreateInput("1", 125, 38, 23, 18)

$defence = GUICtrlCreateLabel("Def:", 95, 60)
GUICtrlSetFont($defence, 8)
$defence = GUICtrlCreateInput("2", 125, 58, 23, 18)

$damage = GUICtrlCreateLabel("Dmg:", 95, 80)
GUICtrlSetFont($damage, 8)
$damage = GUICtrlCreateInput("3", 125, 78, 23, 18)

GUICtrlCreateLabel("Start buff - F11", 10, 80)
GUICtrlCreateLabel("Buff delay (ms):", 10, 170)


$delay1 = GUICtrlCreateInput("", 10, 145, 50, 21)
$buffdelay = GUICtrlCreateInput("", 10, 185, 50, 21)


HotKeySet("{F5}", "left")
HotKeySet("{F6}", "right")
HotKeySet("{F7}", "stop")
HotKeySet("{F11}", "buff")

Func left()
    $iAction = $LEFT
EndFunc   ;==>left

Func right()
    $iAction = $RIGHT
EndFunc   ;==>right

Func stop()
    $iAction = $STOP
EndFunc   ;==>stop

Func buff()
    $iAction = $BUFF
EndFunc   ;==>buff

GUISetState()

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Switch $iAction
        Case $LEFT

            $delay2 = GUICtrlRead($delay1)
            Opt("MouseClickDownDelay", 100)
            Opt("MouseClickDelay", $delay2)
            MouseClick("Left")
            
        Case $RIGHT
            $delay2 = GUICtrlRead($delay1)
            Opt("MouseClickDownDelay", 100)
            Opt("MouseClickDelay", $delay2)
            MouseClick("Right")

        Case $BUFF
            ; Undefined
    EndSwitch
    Sleep(100)
WEnd

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

well you missed the # from the include.

you stuck inside the stop loop , never getting to the While GuiGetMsg() <> $GUI_EVENT_CLOSE loop. you start out inside the $GUI_EVENT_CLOSE loop but as soon as you hit a hot key you go into your other loops and never get back to it.

just put the $msg=GuiGetMsg() inside the stop func and a if $msg=$GUI_EVENT_CLOSE then EXIT

Func stop()
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then Exit
        $var = 0
    WEnd
EndFunc  ;==>stop

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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