YxSilentxY Posted September 7, 2014 Share Posted September 7, 2014 Hey all. I've recently started learning AutoIt, and creating a GUI was the first on the list of things to learn. However, I'm stuck: when I click start on my GUI, the portion of code that happens when that event is processed proceeds as normal, but I cannot exit the window nor can I stop the portion of code. I can't debug the code myself because it seems fine to me. Can someone help please? Thanks. expandcollapse popup#include <GUIConstantsEx.au3> $kevinGUI = GUICreate("AutoIt GUI Example", 335, 100) ;creates GUI box with dimensions (x,y) GUISetState(@SW_SHOW) ;displays the actual GUI box. GUICtrlCreateLabel("Buff 1", 8, 10) ;create a text label $buff1 = GUICtrlCreateInput("", 35, 8, 120) ;creates an input box at position (x,y) and width z GUICtrlCreateLabel("Time", 8, 44) $buffDuration1 = GUICtrlCreateInput("", 35, 40, 120) $startButton = GUICtrlCreateButton("Start", 190, 8, 60) ;creates button at position (x,y) and width z $stopButton = GUICtrlCreateButton("Stop", 260, 8, 60) ;creates stop button at position (x,y) and width z $buff1Timer = TimerInit() While 1 $getEvent = GUIGetMsg() ;continuously checks to see if new events take place Select case $getEvent = $startButton ;if event is start button has been clicked $sendBuff1 = GUICtrlRead($buff1) ;save whatever was typed inside buff1 to variable sendBuff1 $sendBuffDuration1 = GUICtrlRead($buffDuration1) * 1000 ;save whatever was typed inside buffDuration1 to variable sendBuffDuration1 While 1 $buff1TimePassed = TimerDiff($buff1Timer) If $buff1TimePassed > ($sendBuffDuration1) Then Send($sendBuff1) $buff1Timer = TimerInit() EndIf WEnd case $getEvent = $stopButton ExitLoop case $getEvent = $GUI_EVENT_CLOSE ;if event is clicking on [x] button in window ExitLoop ;exit any loops GUIDelete($kevinGUI) ;close the window EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 7, 2014 Moderators Share Posted September 7, 2014 YxSilentxY,Welcome to the AutoIt forums. The reason you find your GUI unresponsive is because once the inner loop (lines 26-34) is entered you have no way of exiting, and so you never check for events after the loop has started. What you need to do is check for events inside that loop. And as this is essentially a spam script, please make sure you read the Forum rules (there is also a link at bottom right of each page) - before you post again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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