Marzupilami Posted July 13, 2016 Share Posted July 13, 2016 Okay, so this is my problem: When I have my code like this, the text updates as I want it to do, but I am unable to use the close/minimize control buttons. $var1 = 0 GUICreate("", 200, 200) $Label1 = GUICtrlCreateLabel($var1, 100, 100, 50, 50) GUICtrlSetFont(-1, 38, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) Exit While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd If I have the other way around, like this, I can close and minimize, but it doesn't update the label text. $var1 = 0 GUICreate("", 200, 200) $Label1 = GUICtrlCreateLabel($var1, 100, 100, 50, 50) GUICtrlSetFont(-1, 38, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) Sleep(1000) Exit Help would be appreciated. Link to comment Share on other sites More sharing options...
funkey Posted July 13, 2016 Share Posted July 13, 2016 You can use AdlibRegister to do this GUICreate("", 200, 200) Global $Label1 = GUICtrlCreateLabel("1", 100, 100, 50, 50) GUICtrlSetFont(-1, 38, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) AdlibRegister("_Count", 1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd Func _Count() Local Static $var1 = 1 $var1 += 1 If $var1 = 4 Then Exit GUICtrlSetData($Label1, $var1) EndFunc GoogleGonnaSaveUs 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2016 Moderators Share Posted July 13, 2016 Marzupilami, Just look for the events during the pauses: #include <GUIConstantsEx.au3> $var1 = 0 GUICreate("", 200, 200) $Label1 = GUICtrlCreateLabel($var1, 100, 100, 50, 50) GUICtrlSetFont(-1, 38, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) _Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) _Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) _Sleep(1000) $var1 += 1 GUICtrlSetData($Label1, $var1) _Sleep(1000) Exit Func _Sleep($iDelay) $nBegin = TimerInit() While TimerDiff($nBegin) < $iDelay Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc 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...
Marzupilami Posted July 13, 2016 Author Share Posted July 13, 2016 @funkey, @Melba23: Thank you for your quick responses! I'm sorry I was a bit unclear. In fact I don't want a counter like the one I showed. What I want is that as thevalue of $var1 changes during the script (my real script is much longer) I want the label text to update with it. Could you help me with that? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2016 Moderators Share Posted July 13, 2016 Marzupilami, It always helps to give as much detail as possible when asking a question - then responders do not waste their time producing code which does not do what is actually required. Two possible solutions to your problem spring to mind: When you reach the part of your script where you change the value of the variable in question, update the label at that point. Use Adlib to read the current value and update the label, much as funkey has already suggested. If you want more focused help, I suggest posting your script so we can see just what might best fit the bill. 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...
funkey Posted July 13, 2016 Share Posted July 13, 2016 (edited) Use the OnEvent-Mode.This makes it easier to handle larger scripts and avoids such problems. Edited July 13, 2016 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2016 Moderators Share Posted July 13, 2016 funkey, I must disagree with that last remark - I have used both OnEvent and MessageLoop modes in large scripts and I would argue that the latter is easier to code and just as efficient. 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