PrintEagle Posted November 27, 2010 Posted November 27, 2010 This is pretty basic, but I've tried for several hours with no luck. I want to be able to run a compiled generic progress bar in the foreground while another operation in on-going. Since the length of time the other operation is running varies, I want to be able to run a second executable that will stop the generic progress bar at any time I choose, and then close it. I can get the progress bar to close using WinKill or WinClose, but the icon for the progress bar is still in the task bar, and is still shown as a running process in Task Manager. What command(s) can I use to get the progress bar to completely close? Here are the two scripts that I am using: ================================================= ProgressOn("Activity Status", "Please Wait", " ") While 1 For $i = 1 to 1000 step 1 sleep(1000) ProgressSet( $i, $i & " ") Next Wend ProgressOff() ================================================= WinClose ( "Activity Status" ) Thanks for any help!
Moderators Melba23 Posted November 27, 2010 Moderators Posted November 27, 2010 PrintEagle, Welcome to the AutoIt forum. Perhaps you might like to use a marquee progress as you have no idea of the time you will need it to run - the marquee style was designed for exactly that reason: #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE) GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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
Valuater Posted November 27, 2010 Posted November 27, 2010 I just hacked my RENSIM MaXoFF program here.... But this code does what you want and you can have a message while it is doing that process. expandcollapse popupGlobal $MaXHide Run_Progess("This is what I want to say") Sleep(5000) GUIDelete($MaXHide) ; use this to remove the progress window MsgBox(0,"Whala","The progreess is gone ", 5) ; you can delete the "Progress.au3" file too Func Run_Progess($Text = "") $MaXHide = GUICreate("MaXoFF HiDDeN") GUISetState(@SW_HIDE, $MaXHide) $Location = "Progress.au3" FileDelete($Location) $program = '#NoTrayIcon' & @CRLF _ & 'Global $Test = True' & @CRLF _ & 'ProgressOn("RENSIMs MaXoFF - Process Window", "' & $Text & '", "Working... ")' & @CRLF _ & 'Local $Percent = 100 / 20, $loop = 0' & @CRLF _ & 'While WinExists("MaXoFF HiDDeN")' & @CRLF _ & ' If $Test And ProcessExists("Defrag.exe") Then' & @CRLF _ & ' ProcessSetPriority ("Defrag.exe", 4)' & @CRLF _ & ' ProcessSetPriority ("dfrgntfs.exe", 4)' & @CRLF _ & ' $Test = False' & @CRLF _ & ' EndIf' & @CRLF _ & ' $loop += 1' & @CRLF _ & ' ProgressSet($Percent * $loop)' & @CRLF _ & ' If $Percent * $loop >= 100 Then $loop = 0' & @CRLF _ & ' Sleep(700)' & @CRLF _ & 'WEnd' FileWrite($Location, $program) If @Compiled = 1 Then $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $Location & '"') Return Run($file_exe) Else $file_au3 = FileGetShortName($Location) Return Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE) EndIf EndFunc ;==>Run_Progess
PrintEagle Posted November 28, 2010 Author Posted November 28, 2010 Try using ProcessClose("Process.exe") in the second script. "Process.exe" is the name of your compiled first script.For some reason "ProcessClose" doesn't work either. Same result as "WinKill" and "WinClose". The progress bar disappears, but the icon stays in the task bar and the process is still running. I've tried this on both WinXP and Vista.I spent some time with the Marquee Progress Bar, and it works OK--but I would rather use the standard progress bar since it doesn't have the little AutoIT logo on it (sorry, AutoIT!). I just can't figure out why I can't completely kill the progress bar!
PrintEagle Posted November 28, 2010 Author Posted November 28, 2010 Compile this script with the attached icon in the same directory and it will look this this. #AutoIt3Wrapper_Icon=Blank.ico GUICreate("", 420, 40, -1, -1) GUICtrlCreateProgress(10, 10, 400, 20, 0x00000008) GUICtrlSendMsg(-1, 0x040A, True, 50) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEnd I like the way your sample looks, but when I run your script it looks just like the one I made! Blue title bar, and the AutoIT logo was still in place. I think you've given me enough info to follow through with it, though, unless you want to check it out. Still curious why I can't stop the regular progress bar! Thanks for all your help.
ScottSaltz Posted January 6, 2011 Posted January 6, 2011 (edited) I found this to work to stop a progress bar and start it back up again: Turn OFF: _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETMARQUEE, False, 50) Turn back ON: _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms ($Progress1 is the name of the progress bar that was created) Edited January 6, 2011 by ScottSaltz
ScottSaltz Posted January 6, 2011 Posted January 6, 2011 There is a complete coded sample: #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE) _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, False, 50) ; final parameter is update time in ms SLEEP(1000) Exit EndSwitch WEnd
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