Jump to content
Sign in to follow this  

Cannot exit gui nor stop a portion of code

Recommended Posts


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.

#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
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
  $buff1Timer = TimerInit()
   case $getEvent = $stopButton
   case $getEvent = $GUI_EVENT_CLOSE ;if event is clicking on [x] button in window
ExitLoop ;exit any loops
GUIDelete($kevinGUI) ;close the window

Share this post

Link to post
Share on other sites


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. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


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  


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.