Jump to content

AutoIt Loops Start + Stop


Recommended Posts

Normally, you already have an infinite loop that either keeps your program running or polls the gui for messages... But this could be an example:

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.7.18 (beta)
Author:      myName
Script Function:
    Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $gInfiniteLoop = false
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 262, 125, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Button1 = GUICtrlCreateButton("Start", 8, 8, 81, 25)
GUICtrlSetOnEvent(-1, "StartClick")
$Button2 = GUICtrlCreateButton("Stop", 8, 40, 81, 25)
GUICtrlSetOnEvent(-1, "StopClick")
$Button3 = GUICtrlCreateButton("Exit", 8, 72, 81, 25)
GUICtrlSetOnEvent(-1, "ExitClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While Sleep(10)
    If $gInfiniteLoop Then ; Bit redundant
        While $gInfiniteLoop
            #cs
                Infinite Loop
            #ce
        WEnd
    EndIf
    #cs
        Other code?
    #ce
WEnd
Func StartClick()
    $gInfiniteLoop = true
EndFunc
Func StopClick()
    $gInfiniteLoop = False
EndFunc
Func ExitClick()
    Exit
EndFunc
Func Form1Close()
    Exit
EndFunc
Func Form1Maximize()
EndFunc
Func Form1Minimize()
EndFunc
Func Form1Restore()
EndFunc

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Link to comment
Share on other sites

Welcome to the forums Reinhardt1julian :oops:.

Your requirements are all very sensible, but the expectation that someone supply the code is optimistic, and in any case, it would not be the best way to learn. The first thing to do is spend a lot of time reading the help file and playing with the examples. The help is very good and the examples will get you where you want to go although understanding them might be hard at first if you are a raw beginner.Then try to get somewhere with just making a button do something, and when you have a problem post your code no matter how good or bad you think it is and ask for help. You will get lots of help that way and you will learn faster in the end.

This link might be helpful.

Of course later posts might contain very different responses.

Edit: Of course earlier posts might contain very different responses.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...