supersonic Posted April 16, 2008 Share Posted April 16, 2008 Hi, I'm trying to make an countdown sequence for the following while/wend loop: Local $ndmCounter = 5 While $ndmCounter > 0 GUICtrlSetData($ndmButton, "OK (" & $ndmCounter & ")") $ndmCounter = $ndmCounter - 1 Sleep(1000) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($ndmGUI) ExitLoop Case $ndmButton _GUICtrlComboBox_GetLBText($ndmComboBox, _GUICtrlComboBox_GetCurSel($ndmComboBox), $ndmDummy) RegWrite("HKCU\Software\" & $programName, "ndm", "REG_SZ", $ndmDummy) GUIDelete($ndmGUI) ExitLoop EndSwitch WEnd Problems: 1. I can't leave the loop by pressing OK button or closing GUI. 2. A selection (ComboBox) will be only recognized when it was chosen via keyboard. Input via mouse will be ignored. Any ideas? Link to comment Share on other sites More sharing options...
Aceguy Posted April 16, 2008 Share Posted April 16, 2008 (edited) #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 329, 211, 417, 266) $Button1 = GUICtrlCreateButton("Button1", 16, 8, 129, 33, 0) GUICtrlSetOnEvent(-1, "exit_now") $Combo1 = GUICtrlCreateCombo("Combo1", 40, 88, 129, 25) GUICtrlSetData(-1, "a|b|c|d|e|g|h") GUISetOnEvent($GUI_EVENT_CLOSE, "exit_now") GUISetState(@SW_SHOW) Local $ndmCounter = 10 While $ndmCounter > 0 GUICtrlSetData($Button1, "OK (" & $ndmCounter & ")") $ndmCounter = $ndmCounter - 1 Sleep(1000) WEnd Func exit_now() MsgBox(0,"Combo was",guictrlread($Combo1),0) GUIDelete($Form1) EndFunc ;==>exit_now Hope this helps Edited April 16, 2008 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
supersonic Posted April 16, 2008 Author Share Posted April 16, 2008 Perfect! Thank you! Link to comment Share on other sites More sharing options...
supersonic Posted April 17, 2008 Author Share Posted April 17, 2008 Hi, the loop works pretty well now, but when leaving the while/wend loop of function "ndm()" the script hangs. Here's a part of what I have coded so far: expandcollapse popupFunc ndm($ndmTarget) AutoItSetOption("GUIOnEventMode", 1) ; Opt Local $ndmCounter = 10 $ndmArray = xmlQueryGCN($ndmTarget) If $ndmArray = 2 Then Return 2 Else $ndmGUI = GUICreate($programName & " - Network Drive Mapping(s)" & Chr(133), 400, 50, -1, -1) ; Asc("") $ndmButton = GUICtrlCreateButton("OK", 1, 24, 398, 25) GUICtrlSetOnEvent(-1, "exit_now") $ndmComboBox = GUICtrlCreateCombo("", 1, 1, 398, 21) $ndmDummy = RegRead("HKCU\Software\" & $programName, "ndm") If @error Then $ndmDummy = "" EndIf For $i = 1 to $ndmArray[0] If Not StringInStr($ndmArray[$i], "Global", 0) Then If $i <> $ndmArray[0] Then GUICtrlSetData(-1, $ndmArray[$i] & "|", $ndmDummy) Else GUICtrlSetData(-1, $ndmArray[$i], $ndmDummy) EndIf EndIf Next GUISetOnEvent($GUI_EVENT_CLOSE, "exit_now") GUISetState(@SW_SHOW) EndIf ; <...> While $ndmCounter > 0 GUICtrlSetData($ndmButton, "OK (" & $ndmCounter & ")") $ndmCounter = $ndmCounter - 1 Sleep(1000) WEnd EndFunc Func exit_now() MsgBox(0, "", GUICtrlRead($ndmComboBox)) GUIDelete($ndmGUI) EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then GUIDelete($lvGUI) ExitLoop EndIf WEnd Can somebody help? Link to comment Share on other sites More sharing options...
supersonic Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) Maybe the 2nd while/wend loop is responsible for this? Edit: When I disabled the line AutoItSetOption("GUIOnEventMode", 1) ... both loops work fine - but the GUI of function "ndm()" can't be closed. Edited April 17, 2008 by supersonic Link to comment Share on other sites More sharing options...
Aceguy Posted April 17, 2008 Share Posted April 17, 2008 (edited) you only need to put AutoItSetOption("GUIOnEventMode", 1) ONCE at the top of the script. and not in a function. is this you full code.?? GUISetOnEvent($GUI_EVENT_CLOSE, "exit_now") GUISetState(@SW_SHOW) also only need to be once at top of script. Edited April 17, 2008 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock 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