broliukaz Posted March 3, 2014 Posted March 3, 2014 Is there some way to sleep only progress bar functionality, not whole program? example: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 421, 209, 243, 159) $close = GUICtrlCreateButton("Close", 153, 112, 119, 33) $Button1 = GUICtrlCreateButton("Run", 23, 112, 119, 33) $Progress1 = GUICtrlCreateProgress(88, 40, 257, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $close Exit Case $Button1 For $i = 0 To 100 GUICtrlSetData($progress1, $i) Sleep(5) Next sleep(5000) GUICtrlSetData($progress1, 0) EndSwitch WEnd here I can not close the form, because sleep(5000) is still running
Moderators Melba23 Posted March 3, 2014 Moderators Posted March 3, 2014 broliukaz,What exactly are you looking to do? Do you want to stop and restart the Progress? 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
broliukaz Posted March 3, 2014 Author Posted March 3, 2014 (edited) broliukaz, What exactly are you looking to do? Do you want to stop and restart the Progress? M23 No, I want to run another function or just close the form while this "sleep(5000)" is running. I need that progress bar disables after 5 or more seconds, but in this time I need to run another function, like open xls file and read som cell values. Edited March 3, 2014 by broliukaz
Moderators Melba23 Posted March 3, 2014 Moderators Posted March 3, 2014 broliukaz,Then I suggest you do something like this:expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> HotKeySet("x", "_Interrupt") Global $fInterrupt = False $Form1 = GUICreate("Form1", 421, 209, 243, 159) $close = GUICtrlCreateButton("Close", 153, 112, 119, 33) $Button1 = GUICtrlCreateButton("Run", 23, 112, 119, 33) $Progress1 = GUICtrlCreateProgress(88, 40, 257, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $close Exit Case $Button1 For $i = 0 To 100 GUICtrlSetData($Progress1, $i) Sleep(10) ; Give yourself long enough to press the hotKey If $fInterrupt Then ConsoleWrite("Interrupting" & @CRLF) $fInterrupt = False ExitLoop EndIf Next Sleep(5000) GUICtrlSetData($Progress1, 0) EndSwitch WEnd Func _Interrupt() $fInterrupt = True EndFuncPlease ask if you have any questions. 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
Solution mikell Posted March 3, 2014 Solution Posted March 3, 2014 (edited) Melba, He said : while this "sleep(5000)" is running , so maybe can also do this instead of the "sleep(5000)" : For $i = 0 to 500 If $fInterrupt Then ExitLoop ; or : Then something_else() Sleep(10) Next Edited March 3, 2014 by mikell
Sori Posted March 3, 2014 Posted March 3, 2014 You could also use a timer. It would allow you to check if it has been 5 seconds since the last pass, and you could do things during that period. If you need help with your stuff, feel free to get me on my Skype. I often get bored and enjoy helping with projects.
broliukaz Posted March 4, 2014 Author Posted March 4, 2014 Thanks for help! I will try to use your method mikell
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