Sign in to follow this  
Followers 0
PrintEagle

Script to close progress bar

7 posts in this topic

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!

Share this post


Link to post
Share on other sites



PrintEagle,

Welcome to the AutoIt forum. :graduated:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Global $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

NEWHeader1.png

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Compile this script with the attached icon in the same directory and it will look this this.

Posted Image

#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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by ScottSaltz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0