I am a novice and my English is not very good, I hope everyone can understand my statement and give me some advice, thanks.
The code is very suitable for echoing the progress bar when the 7z file is released, but FileGetSize cannot correctly echo the progress bar when encountering multiple sub-volume compressed files.
For example, AA.7z.001, AA.7z.002, AA.7z.003, AA.7z.004, AA.7z.005, AA.7z.006, AA.7z.007, AA.7z.008, AA .7z.009, AA.7z.010…………,
FileGetSize can only progress by AA.7z.001. The card is 100% completed. Please help me, and help me solve the file detection part of FileGetSize. thank.
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Global $Title = "7zip progress echo demo"
$hGUI = GUICreate($Title, 320, 80,-1,-1)
$progressbar = GUICtrlCreateProgress(10, 10, 300, 30)
$btn = GUICtrlCreateButton("Start", 125, 45, 70, 30)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btn
$ExtrTarget = 'E:\DP' ;Release path
$ExtrSource = 'E:\mtest.7z' ;Target file
$UnPack_line = ' x -y -o' & '"'& $ExtrTarget & '"' & ' ' & '"'& $ExtrSource & '"'
_GetPIODataSend2Bar('7za.exe', $UnPack_line, FileGetSize($ExtrSource), $progressbar)
GUICtrlSetData($progressbar, 100)
MsgBox(0, '', 'Successful release')
GUICtrlSetData($progressbar, 0)
GUICtrlSetData($hGUI, "")
Exit
EndSwitch
WEnd
Func _GetPIODataSend2Bar($Execute, $Commandline, $Param, $Ctrl)
Local $Pid, $PIOData, $iPercentage, $iPercentageBefore
$Pid = Run ($Execute & $Commandline, '', @SW_HIDE)
While ProcessExists($Pid)
$PIOData = ProcessGetStats($Execute, 1)
If @error Then
MsgBox(0, '', $Execute)
Else
$iPercentage = Round($PIOData[3]/$Param*100)
If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage <= 100 Then
ConsoleWrite('->-' & $iPercentage & @CRLF)
GUICtrlSetData($Ctrl , $iPercentage)
WinSetTitle($hGUI, "", $Title & " " & $iPercentage & "%")
EndIf
EndIf
WEnd
Return $iPercentage
EndFunc