cording12 Posted June 8, 2012 Share Posted June 8, 2012 I already posted in the GUI section but it may have been the wrong place. Melba23 has been a massive help but I need to get this finished today so I'd like to post it here. My script basically doesn't do two thing. It won't actually input the key's I tell it to and then when it does I can't exit the loops. Can someone please shed some light on this? I read through the 'Interrupt a running function' several times and no matter what I do it just won't work! expandcollapse popup#include <GUIConstantsEx.au3> ; Global $fRunOne = False ; Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ; GUICreate("Test Script", 335, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; Run this function when the [X] is clicked ; GUICtrlCreateLabel("Key", 8, 10) $key1 = GUICtrlCreateInput("", 35, 8, 120) ; No need to set a function for this control as it is not actioned ; GUICtrlCreateLabel("Time", 8, 44) $time1 = GUICtrlCreateInput("", 35, 40, 120) ; No need to set a function for this control as it is not actioned ; $startbutton = GUICtrlCreateButton("Start", 190, 8, 60) GUICtrlSetOnEvent($startbutton, "StartButtonPressed") ; Run this function when the button is pressed ; $stopbutton = GUICtrlCreateButton("Stop", 190, 40, 60) GUICtrlSetOnEvent($stopbutton, "StopButtonPressed") ; Run this function when the button is pressed ; GUISetState(@SW_SHOW) ; While 1 Sleep(1000) ; Check if the flag has been set by the OnEvent function If $fRunOne Then ; Now start the "real" function from within the main code StartButtonPressed() EndIf WEnd ; This function is run when the [X] is clicked Func CLOSEClicked() MsgBox(0, "Stop", "GUI closed. Now Exiting") Exit EndFunc ;==>CLOSEClicked ; ; This function is run when the start button is pressed Func StartButtonPressed() $fRunOne = True while 1 $send1 = GUICtrlRead($key1) $sleep1 = GUICtrlRead($time1) WEnd MsgBox(0, "Read", "Key: " & $send1 & @CRLF & "Sleep: " & $sleep1) Global $fRunOne = False EndFunc ;==>StartButtonPressed ; ; This function is run when the stop button is pressed Func StopButtonPressed() MsgBox(0, "Stop", "Script Stopped. Now Exiting") Exit EndFunc ;==>StopButtonPressed Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 8, 2012 Moderators Share Posted June 8, 2012 cording12, As you state yourself, you already have a thread running on this question, so there is no need for another. We try to stick to just the one thread per question at a time in this forum. 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