Sign in to follow this  
Followers 0
elkgod

How do I get a stop Do...Untill Button to work

4 posts in this topic

I am trying to get a loop that types into notepad and keeps retypeing the text based off the number of times you want through entered number. But the program will not stop unless it finishes. I am trying to ad a stop button that will end the loop but have be unsuccessful any advice an/or help.

CODE
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <EditConstants.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()

Local $Text, $Times, $c, $txt

Local $Stop, $Exit, $Start, $Msg, $sText

Local $filemenu, $runmenu, $startitem, $stopitem, $creditsitem

Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton

Local $file

GUICreate("AutoTalker", 300, 190)

GUICtrlCreateGroup("Text:", 5, 15, 290, 100)

$Text = GUICtrlCreateEdit("Please Read the Read Me file before use", 15,35,270,70, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Repeat Time:", 5, 115, 120, 50)

$Times = GUICtrlCreateInput("", 15, 135, 100, 20, $ES_NUMBER)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Start = GUICtrlCreateButton("&Start", 130, 135, 50, 20)

$Stop = GUICtrlCreateButton("&Stop", 185, 135, 50, 20)

$Exit = GUICtrlCreateButton("&Exit", 240, 135, 50, 20)

$filemenu = GUICtrlCreateMenu("File")

$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$runmenu = GUICtrlCreateMenu("Run")

$startitem = GUICtrlCreateMenuItem("Start", $runmenu)

$stopitem = GUICtrlCreateMenuItem("Stop", $runmenu)

$helpmenu = GUICtrlCreateMenu("About")

$creditsitem = GUICtrlCreateMenuItem("Credits", $helpmenu)

$aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)

GUISetState()

While 1

$Msg = GUIGetMsg()

Select

Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit

Exit

Case $Msg = $Start

$txt=GUICtrlRead($Text)

$c=GUICtrlRead($Times)

Do

$c = $c - 1

WinWaitActive("Untitled - Notepad")

Send("{ENTER}")

Send($txt)

Send("{ENTER}")

Sleep(7000)

Until $c = 0

Case $Msg = $Stop

case $Msg = $startitem

case $Msg = $stopitem

Case $Msg = $exititem

Exit

Case $Msg = $creditsitem

MsgBox(0, "Credits", "")

case $Msg = $aboutitem

msgbox(0, "About", "")

EndSelect

WEnd

EndFunc

Share this post


Link to post
Share on other sites



What do i put in ExitLoop() though

Share this post


Link to post
Share on other sites

Structure your code a bit to make it more readable..:o

This part:

Do
$c = $c - 1
WinWaitActive("Untitled - Notepad")
Send("{ENTER}")
Send($txt)
Send("{ENTER}")
Sleep(7000) 
Until $c = 0oÝ÷ ÙÚ²z-+ÞÊ«±Êâ¦Ö­æ¤#
.ØZ½éuæºw-è}ªZ®ÚÖ®¶­sdgVæ2æ÷FWE6VæBb33c·GB¢bvåvD7FfRgV÷CµVçFFÆVBÒæ÷FWBgV÷C²Â3FVâ¶FFVBFÖV÷W@¢6VæBgV÷C·´TåDU'ÒgV÷C²¢6VæBb33c·GB¢6VæBgV÷C·´TåDU'ÒgV÷C²¢6ÆVWs¢VæD`¤VæDgVæoÝ÷ Ù8^·°®+^Ê«¨§)jëh×6While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
            Exit    
        Case $Msg = $Start
            $txt=GUICtrlRead($Text)
            $c=GUICtrlRead($Times)

        Case $Msg = $Stop
        case $Msg = $startitem
        case $Msg = $stopitem 
        Case $Msg = $exititem
                Exit
        Case $Msg = $creditsitem
                MsgBox(0, "Credits", "")

        case $Msg = $aboutitem
            msgbox(0, "About", "")
        Case else
                If $c > 0 then
                    $c = $c - 1
                    NotepadSend($txt)
                EndIf
EndSelect

WEnd

Note: I have not tested the code. But I hope you get the point and figure out the rest..:)

Share this post


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
Sign in to follow this  
Followers 0