Reinhardt1julian Posted March 18, 2012 Share Posted March 18, 2012 Hi, I'm new. I want to make a GUI with 3 Buttons. The first button is "start" and starts an infinite loop. The second is "stop" and stops the loop. The third should be "exit" and closes the window. What is the code i need for that? Link to comment Share on other sites More sharing options...
Shaggi Posted March 18, 2012 Share Posted March 18, 2012 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: expandcollapse popup#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 More sharing options...
martin Posted March 18, 2012 Share Posted March 18, 2012 (edited) Welcome to the forums Reinhardt1julian .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 March 18, 2012 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 More sharing options...
Shaggi Posted March 18, 2012 Share Posted March 18, 2012 Edit: Of course earlier posts might contain very different responses. Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now