PcExpert Posted April 19, 2007 Share Posted April 19, 2007 (edited) Hi all, How do I create a progress bar that goes to for example 20% when a specified window opens or closes? What I tried: - Tried to do something with the GUICreateProgress - tried to make my own #include <GUIConstants.au3> GUICreate("My GUI", 680, 100) ; will create a dialog box that when displayed is centered $ms = GUICtrlCreateProgress(10, 10, 600, 75) GUICtrlSetData($ms, 20) Sleep(4000) GUICtrlSetData($ms, 40) Sleep(4000) GUICtrlSetData($ms, 60) Sleep(4000) GUICtrlSetData($ms, 80) Sleep(4000) GUICtrlSetData($ms, 100) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend But this sets the progress immediately to 100% and it takes a long time to load. Whats wrong? Edited April 19, 2007 by PcExpert Link to comment Share on other sites More sharing options...
Sokko Posted April 19, 2007 Share Posted April 19, 2007 Take a look at the order of your code. You are creating the GUI, creating the progress bar, setting the progress bar to some values, showing the GUI, and going into the message loop. The reason your progress goes "immediately to 100%" is because you are not displaying the GUI (the @SW_SHOW line) until after you're done setting it to 100%. Link to comment Share on other sites More sharing options...
PcExpert Posted April 19, 2007 Author Share Posted April 19, 2007 So I have to make a button that when clicked it starts? Link to comment Share on other sites More sharing options...
Sokko Posted April 19, 2007 Share Posted April 19, 2007 (edited) You don't need a button. To repeat: Your problem is that you're not showing the window until after you've done the progress bar setting. Remember, any GUI you create is invisible until you show it with GUISetState. Here is your code again, but with the GUISetState line moved up so it happens before you set the progress bar. #include <GUIConstants.au3> GUICreate("My GUI", 680, 100) $ms = GUICtrlCreateProgress(10, 10, 600, 75) GUISetState(@SW_SHOW) GUICtrlSetData($ms, 20) Sleep(4000) GUICtrlSetData($ms, 40) Sleep(4000) GUICtrlSetData($ms, 60) Sleep(4000) GUICtrlSetData($ms, 80) Sleep(4000) GUICtrlSetData($ms, 100) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Edited April 19, 2007 by Sokko Link to comment Share on other sites More sharing options...
PcExpert Posted April 19, 2007 Author Share Posted April 19, 2007 Got it to work. Finally! Link to comment Share on other sites More sharing options...
PcExpert Posted April 19, 2007 Author Share Posted April 19, 2007 One other question: How to make the progress bar still visible even when an other program runs? Link to comment Share on other sites More sharing options...
SadBunny Posted April 19, 2007 Share Posted April 19, 2007 One other question: How to make the progress bar still visible even when an other program runs? It has the 'always on top' by default, so it should actually be visible when you run other apps. You can disable it by using 2 as the 6th parameter. I tried it to be sure, and it did stay on top (always visible) when I taskswitched while it was running... Code used: ProgressOn("test","test") For $a = 1 To 100 Sleep(100) ProgressSet($a) Next ProgressOff() Roses are FF0000, violets are 0000FF... All my base are belong to you. 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