Jump to content
Sign in to follow this  
Fran

progress bar in while statement

Recommended Posts

Fran

Who's going to add my list of "things-I-know-now-that-I-didn't-know-before"?..

I have written a script to run an update for our software, but while it's copying files and running patches and stuff I want a progress bar to be displayed in the gui.

The progress bar does not necessarily have to indicate the progress of what's going on, but it would be nice if it just sort of "animated" with "shininess" while the update is being done. And when it's done, it should stop with the animation.

Geez... I hope you understand what I'm looking for.

Thanx in advance.

Fran

Edited by Fran

Share this post


Link to post
Share on other sites
Melba23

Fran,

If you do mind me again....... :blink:

does not necessarily have to indicate the progress of what's going on, but it would be nice if it just sort of "animated" with "shininess" while the update is being done

This sounds like just the job for a "Marquee" progress: ;)

#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
            Exit
    EndSwitch
WEnd

To be added, or not? :P

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
Fran

M23 comes to the resque once again!

One little problem though...(I've added my script)

I would like the progress bar to only show during the "second window" and when the script comes to a certain point (after cleaning up), it must disapear.

And try as I may, my tiny brain can't get around it.

CreateContentUpdate.au3

Share this post


Link to post
Share on other sites
Melba23

Fran,

That was fun! :P

I have seriously overhauled your script as you will see when you take a look - let me explain why.

- 1. You really like the UDF functions - but there are often built-in AutoIt functions to do what you want. Using them is faster and more reliable - I recommend you do so. Keep the UDF functions for when there is no built-in function to do what you want. :nuke:

- 2. I have rejigged the code so that you can reuse the same GUI until you finally exit. Restarting by running another instance of your script/exe is very bad practice. It is known technically as recursion (something calling itself again before it finishes) and most programmers avoid it like the plague - not least because it does not release the resources used until everything unwinds at the end. Look at how I have arranged things so that you reenter the loop with all the various controls reset. :>

- 3. You were creating and destroying buttons all over the place and you never used 2 of them. It is much easier to rename them using GUICtrlSetData and/or enable/disable them as I have done. :)

- 4. You do not need all this WM_NOTIFY code unless you are using GUIRegisterMsg - which you are not. If you want to know what GUIRegisterMsg is all about, there is a tutorial about it here. :

- 5. I think the progress bar is now where you want it. :blink:

I have commented out some of your code (where I do not have the files to make it run correctly) - to get it to function with your data, just DELETE all the lines ending in ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~. But try running it first so you can see if the general way it runs is what you want. ;)

I have added comments (ending in <<<<<<<<<<<<<<<<<<<<<<<) to explain why I have changed certain things.

And finally......here is the code:

; Script Start - Add your code below here
#RequireAdmin

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <array.au3>
#include <file.au3>
#include <GUIComboBox.au3>
#include <GUIComboBoxEx.au3>
#include <Process.au3>

Opt("TrayAutoPause", 0)
Opt("TrayIconHide", 0)

; Shows the filenames of all files in the current directory.
$aFileList = _FileListToArray("ContentUpdates\mphoto\", "*.*", 1)
If @error Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

; Put array into a string
$sFileList = "|" & _ArrayToString($aFileList, "|", 1)

_Main()

Func _Main()

    Local $textBoxTop = 70, $textBoxLeft = 50, $textBoxWidth = 360, $textBoxHeight = 20

    $gui = GUICreate("Create exe", 460, 250)
    GUICtrlCreatePic("images\gui_header.jpg", 0, 0, 460, 33)
    $box = GUICtrlCreateGroup("Create Update", 30, 45, 400, 160)
    $text = "Choose a theme to make a setup file for download on the website."
    $textBox = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop, $textBoxWidth, $textBoxHeight) ; , ($SS_LEFT)) ; Default style <<<<<<<<
    $hCombo = GUICtrlCreateCombo("", $textBoxLeft, 100, 200, "Choose")
    GUICtrlSetState(-1, $GUI_FOCUS)
    GUICtrlSetData($hCombo, $sFileList)
    $chk = GUICtrlCreateCheckbox("Open folder to view files", 100, 205, 150, 50);, BitOR($BS_AUTOCHECKBOX, $BS_NOTIFY))  ; Default style & no need to Notify <<<<<<<<
    ;GUICtrlSetState($chk, $GUI_HIDE) ;_GUICtrlButton_Show($chk, False) ; Why hide it? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUICtrlSetState($chk, $GUI_CHECKED) ;_GUICtrlButton_SetCheck($chk, $BST_CHECKED) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

    ; This whole button section was really confused <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    ;$butNext = GUICtrlCreateButton("Finish", 350, 210, 90, 30, BitOR($BS_DEFPUSHBUTTON, $BS_NOTIFY)) ; You never use it!!!  <<<<<<<<<<<<<<<<<<
    ;_GUICtrlButton_Show($butNext, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
    $butNext = GUICtrlCreateButton("Next", 350, 210, 90, 30, $BS_DEFPUSHBUTTON) ; $BS_NOTIFY is not necessary for buttons in this script
    $butCancel = GUICtrlCreateButton("Cancel", 250, 210, 90, 30);, ($BS_NOTIFY))
    ;$butRestart = GUICtrlCreateButton("Make another", 250, 210, 90, 30, ($BS_NOTIFY)) ; You never use it!!!  <<<<<<<<<<<<<<<<<<
    ;_GUICtrlButton_Show($butCancel, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $butCancel
                If MsgBox(8196, "Cancel setup", "Are you sure you want to cancel this operation?") = 6 Then Exit

            Case $butNext

                GUICtrlSetState($butNext, $GUI_DISABLE) ; Disable the button while things are happening <<<<<<<<<<<<<<<<<<<
                GUICtrlSetState($butCancel, $GUI_DISABLE) ; Disable the button while things are happening <<<<<<<<<<<<<<<<<<<
                ;
                ;_GUICtrlButton_Enable($butNext, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
                ;_GUICtrlButton_Enable($butCancel, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
                GUICtrlSetState($chk, $GUI_HIDE)

                $themeEXE = GUICtrlRead($hCombo)
                $theme = $themeEXE ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                #cs ~~~~~~~~~~~~~~~~~~~~~~~
                $theme = StringLeft($themeEXE, StringLen($themeEXE) - 16)
                If FileExists("ContentUpdates\mphoto\" & $themeEXE) = False Or GUICtrlRead($hCombo) = "" Then
                    If MsgBox(8244, "ERROR", "Invalid Choice: " & """" & $theme & """" & @CRLF & @CRLF & "Would you like to try again?") = 7 Then Exit
                    Return ;Run("CreateContentUpdate.exe")
                    ;Exit
                    EndIf
                #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                GUICtrlSetState($hCombo, $GUI_HIDE) ; _GUICtrlComboBox_Destroy($hCombo) ; Why destroy it?  ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

                ; Start the progress bar
                $progressbar = GUICtrlCreateProgress($textBoxLeft, 180, 200, 15, $PBS_MARQUEE)
                _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms

                GUICtrlSetData($box, "Compiling EXE - " & $themeEXE) ; $box = GUICtrlCreateGroup("Compiling EXE - " & $themeEXE, 30, 45, 400, 160) ; Just rename it! <<<<<<<<<<<<<<<<<
                $text = "Please be patient while the updateEXE is being compiled."
                $textBox = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                Sleep(2000)
                $text = "Updating variables in ContentUpdate.au3..."
                $textBox1 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 20, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                Sleep(2000)
                ;update variable $theme in ContentUpdate.au3
                #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    $file = "ContentUpdate.au3"
                    $find = "replacethistextwiththemevariablefromcreatecontentupdate.au3"
                    $replace = $theme
                    $retval = _ReplaceStringInFile($file, $find, $replace)
                    If $retval = 0 Then
                        MsgBox(8240, "ERROR", "Error updating variable in: " & $file & @CRLF & " Error: " & @error & @CRLF & @CRLF & "This application will now exit. Please try again." & @CRLF & "If the problem persist, please contact the developer:" & @CRLF & @CRLF & "fran@bowens.co.za" & @CRLF & "083 235 2712")
                        Exit
                    EndIf
                #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                ;copy images and update file
                $text = "Copying images and update file..."
                $textBox2 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 40, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                Sleep(2000) ; ~~~~~~~~~~~~~~~~~~~~~~
                #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                FileCopy("images\contentupdates\" & $theme & ".gif", "temp\themeimage.gif", 9) ; ~~~~~~~~~~~~~~~
                ; FileCopy("ContentUpdates\mphoto\" & $themeEXE, "temp\update.exe",9)
                #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                ;compile script to exe using DOS command.
                $text = "Compiling script to exe... (This might take a while)"
                $textBox3 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 60, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                Sleep(2000) ; ~~~~~~~~~~~~~~~~~~~~~~
                #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                ;                       _RunDOS("""C:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe"" /in ContentUpdate.au3 /out "& $themeEXE & " /icon images/app.ico")

                ;Cleaning up
                ;$text = "Cleaning up..." ; Too quick to be worth it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                ;$textBox2 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 80, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                FileDelete("temp\update.exe")
                FileDelete("temp\themeimage.gif")
                FileMove($themeEXE, "ContentUpdates\_final\" & $themeEXE, 1)

                ;change variable $theme back to "replacethistextwiththemevariablefromcreatecontentupdate.au3" ContentUpdate.au3
                $file = "ContentUpdate.au3"
                $find = $theme
                $replace = "replacethistextwiththemevariablefromcreatecontentupdate.au3"
                $retval = _ReplaceStringInFile($file, $find, $replace)
                #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


                ; Continue tidying up by clearing the group box <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                GUICtrlSetData($textBox, "")
                GUICtrlSetData($textBox1, "")
                GUICtrlSetData($textBox2, "")
                GUICtrlSetData($textBox3, "")
                GUICtrlDelete($progressbar)

                ; Announce success and determine next move
                If MsgBox(8196, "Success", "Would you like to make another one?") = 7 Then
                    ; No
                    Exit
                Else
                    ; Yes
                    ; If checkbox checked
                    If GUICtrlRead($chk) = 1 Then
                        MsgBox(0, "Checked", 'Running ShellExecute("ContentUpdates\_final")') ; ShellExecute("ContentUpdates\_final")
                        ; You may need to add some code here to wait for the action to end, buut as I have no idea what it is I cannot really say much at the moment! <<<<<<<<<<<<<<
                    EndIf
                    ; Finish tidying up by resetting all controls for the next run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlSetState($butNext, $GUI_ENABLE)
                    GUICtrlSetState($butCancel, $GUI_ENABLE)
                    GUICtrlSetData($box, "Create Update")
                    GUICtrlSetData($textBox, "Choose a theme to make a setup file for download on the website.")
                    GUICtrlSetState($hCombo, $GUI_SHOW)
                    GUICtrlSetData($hCombo, $sFileList) ; This clears the previous selection from the combo <<<<<<<<<<<<<<<<<<<
                    GUICtrlSetState($chk, $GUI_SHOW)
                EndIf

        EndSwitch
    WEnd

EndFunc   ;==>_Main

Please ask if anything is unclear or if the script does not work as you want it to. :P

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
Fran

:blink: - very excited about the new script. Will let you know what I think in a minute.

In the meantime I've found a roundabout way to display the progress bar where I want it, but you won't like it, so I'm not even going to tell you what I did. LOL.

Thanx again man!

Share this post


Link to post
Share on other sites
guinness

Whats the best way in resetting the Scrolling Marquee Progress Bar? Currently I am using _SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, False, 50) to stop it, but how do I reset to 0?


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Fran

guinness.. I don't give answers, I only ask the questions :blink: - M23 will have to help with your problem.

M23,

I have changed the script as you suggested. Thanx a lot. Way faster and less complicated.

Only problem still is at the "return" at the invalid choice doesn't work. The script just exists.

F

CreateContentUpdate_new.au3

Share this post


Link to post
Share on other sites
guinness

With the

Return
you need to
Return <something>

If FileExists("ContentUpdates\mphoto\" & $themeEXE) = False Or GUICtrlRead($hCombo) = "" Then
                    If MsgBox(8244, "ERROR", "Invalid Choice: " & """" & $theme & """" & @CRLF & @CRLF & "Would you like to try again?") = 7 Then Exit
                    Return 0; This is where you are returning the value of 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    ;Exit
                EndIf

And then before the _Main() Function add...

$hTest = _Main()
If $hTest = 0 Then MsgBox(0,"",$hTest)
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Melba23

guinness,

If you want to risk the coloured section remaining visible then your method will work - although if you then restart it, the coloured section does not continue from where it halted, it starts again from the left.

Personally, I just delete the progress bar and create another: ;)

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

$hGUI = GUICreate("Test", 500, 500)
$hProgress = GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms

$hLabel_1 = GUICtrlCreateLabel("", 10,  70, 480, 20)
$hLabel_2 = GUICtrlCreateLabel("", 10, 100, 480, 20)

GUISetState()

GUICtrlSetData($hLabel_1, "Using your method:")

Sleep(2000)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, False)

GUICtrlSetData($hLabel_2, "The coloured section remains visible")

Sleep(3000)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50)

GUICtrlSetData($hLabel_2, "And then restarts from the left")

Sleep(3000)

GUICtrlSetData($hLabel_1, "Using my method:")

GUICtrlDelete($hProgress)
$hProgress = GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)

GUICtrlSetData($hLabel_2, "Now we have a clean bar")

Sleep(3000)

_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50)

GUICtrlSetData($hLabel_2, "And we start again")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

But you choose! :blink:

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
Melba23

Fran,

Sorry, that was in a bit I had commented out! :blink:

You just need another section to the If - look for the ########## lines:

; Script Start - Add your code below here
#RequireAdmin

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <array.au3>
#include <file.au3>
#include <GUIComboBox.au3>
#include <GUIComboBoxEx.au3>
#include <Process.au3>

Opt("TrayAutoPause", 0)
Opt("TrayIconHide", 0)

; Shows the filenames of all files in the current directory.
$aFileList = _FileListToArray("ContentUpdates\mphoto\", "*.*", 1)
If @error Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

; Put array into a string
$sFileList = "|" & _ArrayToString($aFileList, "|", 1)

_Main()

Func _Main()

    Local $textBoxTop = 70, $textBoxLeft = 50, $textBoxWidth = 360, $textBoxHeight = 20

    $gui = GUICreate("Create exe", 460, 250)
    GUICtrlCreatePic("images\gui_header.jpg", 0, 0, 460, 33)
    $box = GUICtrlCreateGroup("Create Update", 30, 45, 400, 160)
    $text = "Choose a theme to make a setup file for download on the website."
    $textBox = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop, $textBoxWidth, $textBoxHeight) ; , ($SS_LEFT)) ; Default style <<<<<<<<
    $hCombo = GUICtrlCreateCombo("", $textBoxLeft, 100, 200, "Choose")
    GUICtrlSetState(-1, $GUI_FOCUS)
    GUICtrlSetData($hCombo, $sFileList)
    $chk = GUICtrlCreateCheckbox("Open folder to view files", 100, 205, 150, 50);, BitOR($BS_AUTOCHECKBOX, $BS_NOTIFY))  ; Default style & no need to Notify <<<<<<<<
    ;GUICtrlSetState($chk, $GUI_HIDE) ;_GUICtrlButton_Show($chk, False) ; Why hide it? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUICtrlSetState($chk, $GUI_CHECKED) ;_GUICtrlButton_SetCheck($chk, $BST_CHECKED) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

    ; This whole button section was really confused <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    ;$butNext = GUICtrlCreateButton("Finish", 350, 210, 90, 30, BitOR($BS_DEFPUSHBUTTON, $BS_NOTIFY)) ; You never use it!!! <<<<<<<<<<<<<<<<<<
    ;_GUICtrlButton_Show($butNext, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
    $butNext = GUICtrlCreateButton("Next", 350, 210, 90, 30, $BS_DEFPUSHBUTTON) ; $BS_NOTIFY is not necessary for buttons in this script
    $butCancel = GUICtrlCreateButton("Cancel", 250, 210, 90, 30);, ($BS_NOTIFY))
    ;$butRestart = GUICtrlCreateButton("Make another", 250, 210, 90, 30, ($BS_NOTIFY))
    ;_GUICtrlButton_Show($butCancel, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $butCancel
                If MsgBox(8196, "Cancel setup", "Are you sure you want to cancel this operation?") = 6 Then Exit

            Case $butNext

                GUICtrlSetState($butNext, $GUI_DISABLE) ; Disable the button while things are happening <<<<<<<<<<<<<<<<<<<
                GUICtrlSetState($butCancel, $GUI_DISABLE) ; Disable the button while things are happening <<<<<<<<<<<<<<<<<<<
                ;
                ;_GUICtrlButton_Enable($butNext, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
                ;_GUICtrlButton_Enable($butCancel, False) ; Use built-in commands - faster and easier <<<<<<<<<<<<<<
                GUICtrlSetState($chk, $GUI_HIDE)

                $themeEXE = GUICtrlRead($hCombo)
                $theme = StringLeft($themeEXE, StringLen($themeEXE) - 16)
                If FileExists("ContentUpdates\mphoto\" & $themeEXE) = False Or GUICtrlRead($hCombo) = "" Then
                    If MsgBox(8244, "ERROR", "Invalid Choice: " & """" & $theme & """" & @CRLF & @CRLF & "Would you like to try again?") = 7 Then Exit
                    GUICtrlSetState($butNext, $GUI_ENABLE) ; Re-enable the button ########################
                    GUICtrlSetState($butCancel, $GUI_ENABLE) ; Re-enable the button  ###########################
                    GUICtrlSetData($hCombo, $sFileList) ; This clears the invalid selection from the combo ########################
                    ; And we now return to the GUI ##############################################
                Else
                    ; Everthing is fine so let us go on ##################################
                    GUICtrlSetState($hCombo, $GUI_HIDE) ; _GUICtrlComboBox_Destroy($hCombo) ; Why destroy it?  ; Use built-in commands - faster and easier <<<<<<<<<<<<<<

                    ; Start the progress bar
                    $progressbar = GUICtrlCreateProgress($textBoxLeft, 180, 200, 15, $PBS_MARQUEE)
                    _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms

                    GUICtrlSetData($box, "Compiling EXE - " & $themeEXE) ; $box = GUICtrlCreateGroup("Compiling EXE - " & $themeEXE, 30, 45, 400, 160) ; Just rename it! <<<<<<<<<<<<<<<<<
                    $text = "Please be patient while the updateEXE is being compiled."
                    $textBox = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                    Sleep(2000)
                    $text = "Updating variables in ContentUpdate.au3..."
                    $textBox1 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 20, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                    Sleep(2000)
                    ;update variable $theme in ContentUpdate.au3
                    #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        $file = "ContentUpdate.au3"
                        $find = "replacethistextwiththemevariablefromcreatecontentupdate.au3"
                        $replace = $theme
                        $retval = _ReplaceStringInFile($file, $find, $replace)
                        If $retval = 0 Then
                            MsgBox(8240, "ERROR", "Error updating variable in: " & $file & @CRLF & " Error: " & @error & @CRLF & @CRLF & "This application will now exit. Please try again." & @CRLF & "If the problem persist, please contact the developer:" & @CRLF & @CRLF & "fran@bowens.co.za" & @CRLF & "083 235 2712")
                            Exit
                        EndIf
                    #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    ;copy images and update file
                    $text = "Copying images and update file..."
                    $textBox2 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 40, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                    Sleep(2000) ; ~~~~~~~~~~~~~~~~~~~~~~
                    #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    FileCopy("images\contentupdates\" & $theme & ".gif", "temp\themeimage.gif", 9) ; ~~~~~~~~~~~~~~~
                    ; FileCopy("ContentUpdates\mphoto\" & $themeEXE, "temp\update.exe",9)
                    #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    ;compile script to exe using DOS command.
                    $text = "Compiling script to exe... (This might take a while)"
                    $textBox3 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 60, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                    Sleep(2000) ; ~~~~~~~~~~~~~~~~~~~~~~
                    #cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    ;                       _RunDOS("""C:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe"" /in ContentUpdate.au3 /out "& $themeEXE & " /icon images/app.ico")

                    ;Cleaning up
                    ;$text = "Cleaning up..." ; Too quick to be worth it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    ;$textBox2 = GUICtrlCreateLabel($text, $textBoxLeft, $textBoxTop + 80, $textBoxWidth, $textBoxHeight, ($SS_LEFT))
                    FileDelete("temp\update.exe")
                    FileDelete("temp\themeimage.gif")
                    FileMove($themeEXE, "ContentUpdates\_final\" & $themeEXE, 1)

                    ;change variable $theme back to "replacethistextwiththemevariablefromcreatecontentupdate.au3" ContentUpdate.au3
                    $file = "ContentUpdate.au3"
                    $find = $theme
                    $replace = "replacethistextwiththemevariablefromcreatecontentupdate.au3"
                    $retval = _ReplaceStringInFile($file, $find, $replace)
                    #ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


                    ; Continue tidying up by clearing the group box <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlSetData($textBox, "")
                    GUICtrlSetData($textBox1, "")
                    GUICtrlSetData($textBox2, "")
                    GUICtrlSetData($textBox3, "")
                    GUICtrlDelete($progressbar)

                    ; Announce success and determine next move
                    If MsgBox(8196, "Success", "Would you like to make another one?") = 7 Then
                        ; No
                        Exit
                    Else
                        ; Yes
                        ; If checkbox checked
                        If GUICtrlRead($chk) = 1 Then
                            MsgBox(0, "Checked", 'Running ShellExecute("ContentUpdates\_final")') ; ShellExecute("ContentUpdates\_final")
                            ; You may need to add some code here to wait for the action to end, buut as I have no idea what it is I cannot really say much at the moment! <<<<<<<<<<<<<<
                        EndIf
                        ; Finish tidying up by resetting all controls for the next run <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        GUICtrlSetState($butNext, $GUI_ENABLE)
                        GUICtrlSetState($butCancel, $GUI_ENABLE)
                        GUICtrlSetData($box, "Create Update")
                        GUICtrlSetData($textBox, "Choose a theme to make a setup file for download on the website.")
                        GUICtrlSetState($hCombo, $GUI_SHOW)
                        GUICtrlSetData($hCombo, $sFileList) ; This clears the previous selection from the combo <<<<<<<<<<<<<<<<<<<
                        GUICtrlSetState($chk, $GUI_SHOW)
                    EndIf
                EndIf
        EndSwitch
    WEnd

EndFunc   ;==>_Main

All clear? ;)

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
Fran

Thanx Guinness,

I did it like this.. and it works perfectly:

_Main()
If _Main() = 0 Then _Main()

If MsgBox(8244, "ERROR", "Invalid Choice: " & """" & $theme & """" & @CRLF & @CRLF & "Would you like to try again?") = 7 Then Exit
                    Return 0

and M23's way also worked.

Which is the best? - or does it not matter?

F

Share this post


Link to post
Share on other sites
Melba23

Fran,

Mine - but then I would say that anyway! ;)

Seriously, it is better because it remains in the function and does not jump out and then re-enter. :blink:

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
Fran

I thought you'd say something like that :blink:

and I must agree with you, I feel more comfortable with if's and but's than go's and comebacks ;)

I'm really getting into this now... I just want to "AutoIt" everything!!!

Share this post


Link to post
Share on other sites
Melba23

Fran,

I'm really getting into this now... I just want to "AutoIt" everything!!!

Addicitive, isn't it! :blink:

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
guinness

Personally, I just delete the progress bar and create another: :blink:

Thought so! But I wondered if you had some clever magic code up your sleeve! Thanks for the advice ;)

Mine - but then I would say that anyway! :P

True, because I was just explaining why the Return wasn't returning, but I couldn't see the point in it. Correct me if I am wrong but I prefer using Return in long Functions.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Melba23

guinness,

No magic code I am afraid! :blink:

I was just explaining why the Return wasn't returning, but I couldn't see the point in it

You needed to see the original code to understand why there was a Return there. When I rewrote it there was no need at all - it was just that I had commented out that part of the script so it ran on my machine and forgot the Return was still there! ;)

I prefer using Return in long Functions

As indeed you should - as long as you have something to return to! But in this example there is not really a main script - everything is in the function. :P

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
Yoriz

Whats the best way in resetting the Scrolling Marquee Progress Bar? Currently I am using _SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, False, 50) to stop it, but how do I reset to 0?

Added another method of reseting the progress to a clean bar is setting style $GUI_SS_DEFAULT_PROGRESS.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

$hGUI = GUICreate("Test", 500, 500)
$hProgress = GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms

$hLabel_1 = GUICtrlCreateLabel("", 10,  70, 480, 20)
$hLabel_2 = GUICtrlCreateLabel("", 10, 100, 480, 20)

GUISetState()

GUICtrlSetData($hLabel_1, "Using your method:")

Sleep(2000)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, False)

GUICtrlSetData($hLabel_2, "The coloured section remains visible")

Sleep(3000)
_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50)

GUICtrlSetData($hLabel_2, "And then restarts from the left")

Sleep(3000)

GUICtrlSetData($hLabel_1, "Using Melba23 method:")

GUICtrlDelete($hProgress)
$hProgress = GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)

GUICtrlSetData($hLabel_2, "Now we have a bar with a bit of green on the left")

Sleep(3000)

_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50)

GUICtrlSetData($hLabel_2, "And we start again")

Sleep(3000)

GUICtrlSetData($hLabel_1, "Using Yoriz method:")

GUICtrlSetStyle($hProgress, $GUI_SS_DEFAULT_PROGRESS)

GUICtrlSetData($hLabel_2, "Now we have a totally clean bar")

Sleep(3000)

GUICtrlSetStyle($hProgress, $PBS_MARQUEE)

_SendMessage(GUICtrlGetHandle($hProgress), $PBM_SETMARQUEE, True, 50)

GUICtrlSetData($hLabel_2, "And we start again")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites
Melba23

Yoriz,

Not that I am being sensitive, but I do not get "a bar with a bit of green on the left" - I get exactly the same "totally clean bar" that your code produces. ;)

But that is on Vista where the progress bars are a bit strange. :blink:

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
Yoriz

Heya Melba23,

Im on xp, here is a shot of what it looks like for me, its not a big deal :blink: just something i noticed.

My method was more about not needing to delete and recreate the progress, its always good to have lots of ways to solve something.

post-50911-12785254998532_thumb.jpg


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

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  

×