penggilas2 Posted December 10, 2009 Posted December 10, 2009 (edited) Now I`m learning about Progress... and I create progress for ImageX this my script... #RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("ImageX Only For Me", 372, 100, 223, 114) $Button1 = GUICtrlCreateButton("Mount", 40, 8, 97, 33, $WS_GROUP) $Button2 = GUICtrlCreateButton("Unmount", 224, 8, 105, 33, $WS_GROUP) $Progress1 = GUICtrlCreateProgress(0, 56, 369, 25) GUISetState(@SW_SHOW) $imagex = @ProgramFilesDir &"\Windows AIK\tools\x86\imagex.exe" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Mou = ($imagex & " /mountrw f:\wimboot\test.wim 1 f:\wimboot\test") Run ($Mou) GUICtrlSetData($Progress1,$Mou & " percent") Case $Button2 Run ($imagex & " /unmount f:\wimboot\test /commit") EndSwitch WEnd How set progress with % function.. Imagex mount from 0 % and 100 % is done... then exit cmd imagex.. How to make my progress run same with % in imagex cmd.. please .. thank you.. Edited December 10, 2009 by penggilas2
NerdFencer Posted December 10, 2009 Posted December 10, 2009 You can use... GUICtrlSetData($Progress1,percentage) to set the percent on the gui control I dont know how you would gauge the actual progress of the operation though. _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell
penggilas2 Posted December 12, 2009 Author Posted December 12, 2009 You can use... GUICtrlSetData($Progress1,percentage) to set the percent on the gui control I dont know how you would gauge the actual progress of the operation though. Test.Wim file is 97.786.647 bytes When Mount to test folder is 244.406.193 bytes I want set my progress when 100% is done then Exitloop.. I got Rtconsole.exe and script from this forum then create script like this : just Copy paste from script in this forum.. expandcollapse popup#RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("ImageX Only For Me", 372, 100, 223, 114) $Button1 = GUICtrlCreateButton("Mount", 40, 8, 97, 33, $WS_GROUP) $Button2 = GUICtrlCreateButton("Unmount", 224, 8, 105, 33, $WS_GROUP) $Progress1 = GUICtrlCreateProgress(0, 56, 369, 25) GUISetState(@SW_SHOW) $imagex = @ProgramFilesDir &"\Windows AIK\tools\x86\imagex.exe" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Mou = ($imagex & " /mountrw f:\wimboot\test.wim 1 f:\wimboot\test") ShowProgress($Mou, 'Applying...') Case $Button2 $Mou = ($imagex & " /unmount f:\wimboot\test /commit") ShowProgress($Mou, 'Applying...') EndSwitch WEnd Func ShowProgress($Mou, $ImageType) $foo = Run('"' & @ScriptDir & '\rtconsole.exe" ' & $Mou, '', '', 2 + 4) $line1 = '0' ProgressOn('Imagex', 'ImageX', $line1) While 1 $line = StdoutRead($foo) If StringInStr($line, 'ImageX Tool for Windows') <> 0 Then $line = 0 If StringInStr($line, 'Progress: 100%') <> 0 Then ExitLoop If StringInStr($line, 'Error') <> 0 Then ExitLoop $line = StringStripWS($line, 7) If StringInStr($line, ',') <> 0 Then EndIf $line3 = StringSplit($line, @CRLF) $line1 = StringSplit($line, '%') $line = StringRight($line1[1], 2) If @error Then ExitLoop If $line <> "" Then ProgressSet($line, $line3[1], $ImageType) EndIf WEnd ProgressOff() EndFunc ;==>ShowProgress But when test.wim is mounted I can`t exitloop.. Gui can`t be close or when commit test.wim done or success or mount is error progress won`t close.. Please correct my script..
frenchbeast Posted December 4, 2010 Posted December 4, 2010 I just wanted to share a little trick for the progress Capture the console output and grab the percentage $IMAGEX_PATH = <Path to imagex.exe> $PACKAGE_NAME = <Path to your WIM package> $DRIVE_DEST = <Drive Destination (i.e.: C:)> $SPLASH_TITLE = "My Company Imaging" ;~ Let's capture the processID in order to grab the StdOut ... Local $ProcessID = Run($IMAGEX_PATH&" /apply """&$PACKAGE_NAME&""" 1 """&$DRIVE_DEST,"",@SW_HIDE, 0x8) ;~ Reading the output from the processID ProgressOn($SPLASH_TITLE,"Applying image "&$PACKAGE_NAME) While 1 $fCurLine = StdoutRead($ProcessID) ;~ I read what the ProcessID write to the console If @error Then ExitLoop ;~ Make sure to exit when the ProcessID is finished $fLines = StringSplit($fCurLine,@CRLF,2) ;~ Splitting the result which can contain several lines For $fLine In $fLines ;~ Treating each line individually $fLine = StringStripWS(StringStripCR($fLine),3) ;~ Cleaning up the current string If $fLine<>"" And StringRegExp($fLine,"\[\s*\d+%\s*\]",0) Then ;~ I select only the lines containing a % $fPercentage = StringRegExpReplace($fLine,"^.*\[\s*(\d+)%\s*\].*$","$1") ;~ Get the percentage with a regular expression ProgressSet(Int($fPercentage),$fLine) ;~ Finally apply the percentage to the progress bar and the text EndIf Next Wend ProgressOff() doestergaard and Catdaddy 2
tazlikesrobots Posted July 28, 2014 Posted July 28, 2014 I just wanted to share a little trick for the progress Capture the console output and grab the percentage $IMAGEX_PATH = <Path to imagex.exe> $PACKAGE_NAME = <Path to your WIM package> $DRIVE_DEST = <Drive Destination (i.e.: C:)> $SPLASH_TITLE = "My Company Imaging" ;~ Let's capture the processID in order to grab the StdOut ... Local $ProcessID = Run($IMAGEX_PATH&" /apply """&$PACKAGE_NAME&""" 1 """&$DRIVE_DEST,"",@SW_HIDE, 0x8) ;~ Reading the output from the processID ProgressOn($SPLASH_TITLE,"Applying image "&$PACKAGE_NAME) While 1 $fCurLine = StdoutRead($ProcessID) ;~ I read what the ProcessID write to the console If @error Then ExitLoop ;~ Make sure to exit when the ProcessID is finished $fLines = StringSplit($fCurLine,@CRLF,2) ;~ Splitting the result which can contain several lines For $fLine In $fLines ;~ Treating each line individually $fLine = StringStripWS(StringStripCR($fLine),3) ;~ Cleaning up the current string If $fLine<>"" And StringRegExp($fLine,"\[\s*\d+%\s*\]",0) Then ;~ I select only the lines containing a % $fPercentage = StringRegExpReplace($fLine,"^.*\[\s*(\d+)%\s*\].*$","$1") ;~ Get the percentage with a regular expression ProgressSet(Int($fPercentage),$fLine) ;~ Finally apply the percentage to the progress bar and the text EndIf Next Wend ProgressOff() Thank you so much for posting this! you saved me a good deal of tinkering to get something like this working!
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