Что нового

Продвинутый показ выполнения прогресса

Tosyk

Новичок
Сообщения
206
Репутация
0
Что я пытаюсь выполнить?
хочу чтобы скрипт показывал процесс не только мгновенно от 0-100%, но и чтобы в середине работы на определённых участках процент немного прибавлялся

Как я это пытался/ась выполнить?
сделал такой скрипт (обработка файла перетаскиванием на скрипт) и пытаюсь вставлять UpdateProgress() с описанием - безуспешно
Код:
#include <File.au3>
#Include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

If Not $CmdLine[0] Then
	MsgBox(0, "Usage", "Drop file(s) on " & @ScriptName)
	ConsoleWrite("Usage: " & @ScriptName & " <file>" & @CRLF)
	Exit
EndIf

AutoItSetOption("MustDeclareVars", 1)
HotKeySet("{ESC}", "Terminate")

Local $i ; input file
Local $sSourceFile, $sDestFile, $sDestPath, $sExePath, $Dir, $sSourceFileXXX, $Form1, $ProgressBar1, $Label, $Progress, $Progress1
Local $sDrive, $sFolder, $sFileName, $sExt, $sParams, $sRunWait, $sFilePy, $sDivider, $sBlendAddon, $sFileDirPath
Local $sMainApp = 'mk11_model_morph_mirror.exe', $sOO2DLL = 'oo2core_5_win64.dll'

If $CmdLine[0] <> 0 Then
	If FileExists(@ScriptDir & '\' & $sMainApp) And FileExists(@ScriptDir & '\' & $sOO2DLL) Then
		GUIFunc()
		MainLoop()
	Else
		MsgBox(0, "Application file(s) not found", "Can't find " & @ScriptDir & '\' & $sMainApp & " and " & @ScriptDir & '\' & $sOO2DLL)
		ConsoleWrite("Usage: " & @ScriptName & " <file>" & @CRLF)
	EndIf
Else
   MsgBox(0, "Usage", "Drop 'Mortal Kombat 11' XXX asset file(s) on " & @ScriptName)
   ConsoleWrite("Usage: " & @ScriptName & " <file>" & @CRLF)
EndIf

Func GUIFunc()
	#Region ### START Koda GUI section ### Form=
	$Form1 = GUICreate("Converting files...", 300, 100, -1, -1);, $WS_POPUP) ;, $WS_EX_TOOLWINDOW)
	$Label = GUICtrlCreateLabel("", 20, 25, 220, 20, $SS_LEFT) ;, $WS_EX_TOPMOST)
	$Progress1 = CreateProgress(20, 46, 260, 20)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###
EndFunc   ;==>GUIFunc

Func MainLoop()
	For $i = 1 To $CmdLine[0]
		$sSourceFile = $CmdLine[$i]
		_PathSplit($sSourceFile, $sDrive, $sFolder, $sFileName, $sExt)
		GUICtrlSetData($ProgressBar1, ($i / $CmdLine[0]) * 100)

		If FileExists($sSourceFile) Then
			Settings()
			ConsoleWrite("Full converting path: " & $sRunWait & @LF)
		Else
		   MsgBox(0, '', "File [" & $sSourceFile & "] not found")
		EndIf

		UpdateProgress($Progress1, ($i / $CmdLine[0]) * 100)
		GUICtrlSetData($Label, $sFileName & $sExt)
		Sleep(650)
	Next

	GUICtrlSetData($Label, "Converting complete")
	Sleep(800)
EndFunc   ;==>MainLoop

Func Settings()

		UpdateProgress($Progress1, ($i / $CmdLine[0]) * 30)
		GUICtrlSetData($Label, "Folder creating")
		Sleep(650)

	$sFileDirPath = $sDrive & '\' & $sFolder & '\' & $sFileName
	DirCreate($sFileDirPath)

		UpdateProgress($Progress1, ($i / $CmdLine[0]) * 60)
		GUICtrlSetData($Label, "Process files")
		Sleep(650)

	$sExePath = @ScriptDir & '\' & $sMainApp
	$sSourceFileXXX = $sFileName & $sExt

	$sRunWait = $sExePath & " " & $sSourceFileXXX
	RunWait(@ComSpec & ' /c ' & $sRunWait, '', @SW_HIDE)

		UpdateProgress($Progress1, ($i / $CmdLine[0]) * 85)
		GUICtrlSetData($Label, "Moving folders")
		Sleep(650)

	FileMove(@WorkingDir & '\_cut.bat', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)
	FileMove(@WorkingDir & '\log.txt', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)
	FileMove(@WorkingDir & '\' & $sFileName & '.export.txt', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)
	FileMove(@WorkingDir & '\' & $sFileName & '.import.txt', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)
	FileMove(@WorkingDir & '\' & $sFileName & '.names.txt', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)
	FileMove(@WorkingDir & '\' & $sFileName & '.unp', @WorkingDir & '\' & $sFileName, $FC_OVERWRITE)

	DirMove(@WorkingDir & '\textures', @WorkingDir & '\' & $sFileName & '\textures')
	DirMove(@WorkingDir & '\skeletalmesh.raw', @WorkingDir & '\' & $sFileName & '\skeletalmesh.raw')
	DirMove(@WorkingDir & '\staticmesh.raw', @WorkingDir & '\' & $sFileName & '\staticmesh.raw')
	DirMove(@WorkingDir & '\statics', @WorkingDir & '\' & $sFileName & '\statics')
	DirMove(@WorkingDir & '\models', @WorkingDir & '\' & $sFileName & '\models')
EndFunc   ;==>Settings

;---------------------------------------------------------------
;- Enhanced Progress widget
;---------------------------------------------------------------
Func CreateProgress($x, $y, $w, $h, $Label="")
	Dim $Progress[2]
	$Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h) ; this is progress bar
	$Progress[1] = GuiCtrlCreateLabel($Label, $x+0, $y-21, '', '', $SS_RIGHT) ; this is percentage label
	GUICtrlSetFont($Progress[1], 11, 500, 0, "")
	GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT)
	Return $Progress
EndFunc

Func UpdateProgress($ProgressID, $Percent, $Label="")
	GUICtrlSetData($ProgressID[0], $Percent)
	GUICtrlSetData($ProgressID[1], $Label & Round($Percent, 1) & "%")
EndFunc

Func Terminate()
   Exit
EndFunc   ;==>Terminate

Exit (0)


Что я ожидаю от выполненных действии?
чтобы скрипт в определённые моменты показывал прогресс выполнения не от 0 до 100 а с промежуточными этапами

Что происходит на самом деле?
скрипт при обработке файла показывает заполнение бара от 0 да 100 и может так висеть на 100% а файл всё ещё не обработался и так может продолжаться долго в зависимости от размера обрабатываемого файла
 
Автор
Tosyk

Tosyk

Новичок
Сообщения
206
Репутация
0
в дополнение: как сделать чтобы прогресс работал так же и относительно размера обрабатываемого файла?

я не могу найти ответы на эти вопросы. и на англоязычном ресурсе тоже. возможно я не очень хорошо понимаю как применить эти знания к моему случаю

подскажите пожалуйста
 
Верх