Jump to content
Sign in to follow this  
ilovedjians

Stopping a Function

Recommended Posts

ilovedjians

Hey. I'm new here. I'd like to ask how do you stop a function after clicking the Stop button?

I tried this

$Form1 = GUICreate("Simple Bot", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Auto Press Up", 8, 8, 305, 121)
$Button1 = GUICtrlCreateButton("Start", 24, 32, 75, 25)
$Button2 = GUICtrlCreateButton("Stop", 112, 32, 75, 25)
$Input1 = GUICtrlCreateInput("Not Started", 192, 32, 65, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Delay (s)", 24, 72, 45, 17)
$Input2 = GUICtrlCreateInput("5", 24, 88, 233, 21)
GUICtrlSetLimit(-1, 10000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

    Dim $On
    $On = False

While 1
$DelayVal = GUICtrlRead($Input2)
$DelayVal = $DelayVal
$nMsg = GUIGetMsg()
    If $On = True Then
        WinWaitActive("BLAH")
        Send ("{UP}")
        Sleep (5000)
        Send ("{UP}")
        Sleep ($DelayVal * 1000)
    EndIf
    Select
        Case $nMsg = $Button1
            GUICtrlSetData($Input1, "Started!")
            $On = True

        Case $nMsg = $Button2
            GUICtrlSetData($Input1,"Not Started")
            If $On = True Then
                $On = False
            EndIf

        Case $nMsg = $GUI_EVENT_CLOSE
            Exit

    EndSelect

WEnd

After trying it, I notice right after I click START, I couldn't get it to stop even after clicking the STOP button. I can't even close it. Any idea why? Thanks in advance. =)

Share this post


Link to post
Share on other sites
sleepydvdr

Hey. I'm new here. I'd like to ask how do you stop a function after clicking the Stop button?

I tried this

[autoit]$Form1 = GUICreate("Simple Bot", 615, 438, 192, 124)

$Group1 = GUICtrlCreateGroup("Auto Press Up", 8, 8, 305, 121)

$Button1 = GUICtrlCreateButton("Start", 24, 32, 75, 25)

$Button2 = GUICtrlCreateButton("Stop", 112, 32, 75, 25)

$Input1 = GUICtrlCreateInput("Not Started", 192, 32, 65, 21)

....

First line of your code has a naughty word: Bot.

http://www.autoitscript.com/forum/forum-2/announcement-13-forum-rules/


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites
ilovedjians

Oh come on.. I'm just trying to play around with AutoIT since I just downloaded it and learnt a few things. And how does automatically pressing UP harm anything? :)

Share this post


Link to post
Share on other sites
Jos

Oh come on.. I'm just trying to play around with AutoIT since I just downloaded it and learnt a few things. And how does automatically pressing UP harm anything? :)

The rules are clear...

As to your question. Since you constantly active window "blah" you probably are unable to click on anything else.

Use a Hotkey.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.