Jump to content
VollachR

Progress bar for silently run program

Recommended Posts

Hi,

I'd like to show a progress bar for an operation performed by an external program my script is running silently, I want to show it in a GUI I created using the GUICtrlCreateProgress but I have no idea how to do it.

The important thing to point out is that there's no way of knowing how long the external program will run, as it is a file splitter and it depends on the size of file it splits and the split parts size.

Can someone point me in the right direction or give me an example how to do so?

This is my RunWait command:

RunWait($MYFILES1 & '\fsplit.exe -split ' & $Size & ' mb ' & $File & " -f " & $File & "." & $extension)

It uses multiple variables declared and set earlier in the script, how will I got about having the progress of that command shown using GUICtrlCreateProgress ? Is it possible?

Thank you.


Ron Vollach
Microsoft Certified Professional (MCP)
Creator of Ultimate Conversion Compressor (UCC)
UCC Wikia

Share this post


Link to post
Share on other sites

RunWait pauses your script until fsplit.exe has finished, so i suggest using the style Marquee for the progressbar. Here a small example:

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


$Form1 = GUICreate("Form1", 545, 125, 5, 5);, $WS_POPUP, $WS_EX_TOOLWINDOW)
$Button1 = GUICtrlCreateButton('&STOP Marquee', 5, 5, 200)
$Timer = GUICtrlCreateLabel('Zeit: ', 470, 5, 70)
$Progress1 = GUICtrlCreateProgress(0, 95, 545, 25, $PBS_MARQUEE)
$hProgress = GUICtrlGetHandle($Progress1)
_SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
GUISetState(@SW_SHOW)
$dtStart = TimerInit()


AdlibRegister('Timer', 1000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            If GUICtrlRead($Button1) = '&STOP Marquee' Then
                _SendMessage($hProgress, $PBM_SETMARQUEE, False, 10)
                GUICtrlSetData($Button1, '&Resume Marquee')
            Else
                _SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
                GUICtrlSetData($Button1, '&STOP Marquee')
            EndIf
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Timer()
    Local $Time = TimerDiff($dtStart) / 1000
    Local $HOUR = Int($Time / 3600)
    Local $MIN = Int(($Time - $HOUR * 3600) / 60)
    Local $SEC = $Time - $HOUR * 3600 - $MIN * 60
    GUICtrlSetData($Timer, StringFormat("%02i:%02i:%02i", $HOUR, $MIN, $SEC))
EndFunc   ;==>Timer

If fsplit in console mode is writing progress to console you can use Run and StdoutRead for updating the real progress.

Share this post


Link to post
Share on other sites

 

4 hours ago, AutoBert said:

RunWait pauses your script until fsplit.exe has finished, so i suggest using the style Marquee for the progressbar. Here a small example:

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


$Form1 = GUICreate("Form1", 545, 125, 5, 5);, $WS_POPUP, $WS_EX_TOOLWINDOW)
$Button1 = GUICtrlCreateButton('&STOP Marquee', 5, 5, 200)
$Timer = GUICtrlCreateLabel('Zeit: ', 470, 5, 70)
$Progress1 = GUICtrlCreateProgress(0, 95, 545, 25, $PBS_MARQUEE)
$hProgress = GUICtrlGetHandle($Progress1)
_SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
GUISetState(@SW_SHOW)
$dtStart = TimerInit()


AdlibRegister('Timer', 1000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            If GUICtrlRead($Button1) = '&STOP Marquee' Then
                _SendMessage($hProgress, $PBM_SETMARQUEE, False, 10)
                GUICtrlSetData($Button1, '&Resume Marquee')
            Else
                _SendMessage($hProgress, $PBM_SETMARQUEE, True, 10)
                GUICtrlSetData($Button1, '&STOP Marquee')
            EndIf
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Timer()
    Local $Time = TimerDiff($dtStart) / 1000
    Local $HOUR = Int($Time / 3600)
    Local $MIN = Int(($Time - $HOUR * 3600) / 60)
    Local $SEC = $Time - $HOUR * 3600 - $MIN * 60
    GUICtrlSetData($Timer, StringFormat("%02i:%02i:%02i", $HOUR, $MIN, $SEC))
EndFunc   ;==>Timer

If fsplit in console mode is writing progress to console you can use Run and StdoutRead for updating the real progress.

Well, fsplit does usually run in a command prompt, I intend to eventually set it to start hidden but it does show some kind of progress in the command line console by default, so I think maybe StdoutRead can be used but I'm not sure.

The progress it shows is not percentage but actually text line telling which part is is being created.

Anyway, here's a sample of the GUI I created, I need the progress to be shown in it and I need the OK button to become clickable only after the fsplit command ended.

#Region ### START Koda GUI section ### Form=
$Form13 = GUICreate("TITLE", 615, 500, 192, 124)
GUISetBkColor(0x0871AB)
GUISetIcon("UCC.ico")
$Text = GUICtrlCreateLabel("LINE1" & @CRLF & "LONG TEXT" & @CRLF & @CRLF & "LINE" & @CRLF & "TEXT" & @CRLF & "LINE" & @CRLF & @CRLF & "TEXT" & @CRLF & @CRLF, 15, 15, 600, 230)
GUICtrlSetFont($Text, 10, 400, 0, "Arial Rounded MT Bold")
GUICtrlSetColor($Text, 0xC5D3ED)
$Text2 = GUICtrlCreateLabel("LINE" & @CRLF & "TEXT" & @CRLF & "Part of the " & "TEXT" & " (UCC) Tool by " & "AUTHOR" & @CRLF & "LINE" & @CRLF & @CRLF & _
"STEP " & "Number" & ": Splitting " & "Filename" & " into " & "Size" & " Parts" & @CRLF & @CRLF & "Please Wait..." , 15 , 230, 500,170)
GUICtrlSetFont($Text2, 10, 400, 0, "Arial Rounded MT Bold")
GUICtrlSetColor($Text2, 0xC5D3ED)
$Logo = GUICtrlCreatePic(@TempDir & "\UCC\GUILogo.jpg", 490, 5, 130, 130)
GUICtrlSetState($Logo, $GUI_DISABLE)
$SplitProgressL = GUICtrlCreateLabel("Progres Bar:", 15, 400, 520, 15)
GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold")
GUICtrlSetColor(-1, 0xC5D3ED)
$SplitProgress = GUICtrlCreateProgress(15, 415, 580, 15)
$btnOK = GUICtrlCreateButton("OK", 510, 470, 100, 23)
GUISetState() ; display the GUI
#EndRegion ### END Koda GUI section ###
While 1
            $Msg = GUIGetMsg()
            Sleep(10)
            Switch $Msg
                Case $GUI_EVENT_CLOSE, $btnOK
                    GUIDelete()
                    ExitLoop
            EndSwitch
        WEnd

I of course removed all the variable I actually used from this sample for the example purpose, anyway, I would I go about making that GUI progress bar work with the fsplit command? 

I don't really care the type of progress bar animation, as long as it is shown within the GUI window and it works.

BTW, I'm attaching an image showing the fsplit CMD console output.

28582953138_95f920326f_o.png

 

Edited by VollachR
Added more info

Ron Vollach
Microsoft Certified Professional (MCP)
Creator of Ultimate Conversion Compressor (UCC)
UCC Wikia

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

  • Similar Content

    • By adjist
      Hello all! 
       
      Getting this error :
      (22) : ==> Variable used without being declared.: if $vNumber = 0 Then if ^ ERROR  
      But I'm sure I have defined the variable, as in the top of my script has 
      Global $vNumber = 0  
      How would I go about fixing this?
       
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.19 contains 194 functions divided into these topics:
      window and screen mouse and GUI GUI controls logics and mathematics string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By topgundcp
      Hi, 
      This is my very first post in this forum and am also new with Autoit programming so be easy on me.
      Below is the code that I am trying to get the index of the item selected. No problem getting the text.
      Case $listEdition   ; handle of the list             local $index=0             $item=GUICTRLRead($listEdition)    ; This will return the text in the list             ; ==============   The loop below always fails  ==================             ; Meaning _GUICtrlListView_GetItemSelected($listEdition, $i) always return FALSE. WHY ???????              For $i = 0 To $editionArray[0] - 1   ; The content of the list in an array where editionArray[0] contains total count of items                 If _GUICtrlListView_GetItemSelected($listEdition, $i) Then                     $index = $i                     exitloop                 EndIf              Next              ;===================================================             ConsoleWrite( "Select Edition:     " & $item & "  index: " & $index & @CR) ....... Please look at the comments in the code & the pix attached.
      _GUICtrlListView_GetItemSelected($listEdition, $i) always returns FALSE.
      Another problem is on the list. It also populate  the total count of items from the Array. How can I skip this item from populating to the list ?.
      Please advise and thanks

    • By MarkIT
      Hi AutoIT masters,
      Good day! Sorry to have bothered this forum but we really need help. We are working on an automation project that is running on VDI server. The BOTS are in .exe are running fine until AV detected them and deleted the files. The files were re-compiled and AV kept on deleting them. The copy of the .exe BOT deleted were sent to Symantec for whitelisting. After whitelisting, it is no longer deleted but no longer working as designed (showing Line script error). We checked the scripts and there were no issues since we run it using SciTE editor and it performed the desired task. Good thing we found on this thread the solution using .a3x and the BOTS worked fine and no longer deleted. Now, the problem is they are asking why the BOTS won't run in .EXE and what is the reason behind Symantec AV deleting them. We raised a case with Symantec but they cannot provide further information as they are always seeing the file as "False Positive". We even tested with Symantec turned off and those .EXE files are working fine, however, after re-enabling, it got deleted.
      Just seeking help on how to better convince them that it is really Symantec causing the issue and the .a3x file.
    • By antonioj84
      I am not able to use the $GUI_READ_EXTENDED with the  Metro UDF,  any work around ?
      Local $aPos[2] = [$Radio1, $Radio2] For $Radio In $aPos If GUICtrlRead($Radio) = $GUI_UNCHECKED Then ContinueLoop IniWrite($sGUIstate_IniFile, "Data", "POS", GUICtrlRead($Radio, $GUI_READ_EXTENDED)) ;; return the text of the menu item ExitLoop Next  
×
×
  • Create New...