Что нового

Прогресс в консольном приложении

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Скажите пожалуйста если кто знает, как сделать в консольном приложении прогресс?

Пример
Код:
If $CmdLine[0] Then
	
	ConsoleWrite("Please wait..." & @CRLF & @CRLF)
	
	Global $Text
	Global $Progress = 1
	$hFile = FileOpen($CmdLine[1],16)

	While 1
		ConsoleWrite($Process)
		$hRead = FileRead($hFile,2040)
		If @error = -1 Then ExitLoop
		$NoPref = StringTrimLeft($hRead,2)
		$Len = StringLen($NoPref)
		
		For $i = 1 To $Len Step 2
			$sMid = StringMid($NoPref, $i, 2)
			$Text &= _StringReverse($sMid)
		Next
		
        $sFormat = BinaryToString("0x" & $Text)
        FileWrite($CmdLine[1] & ".bin", $sFormat & @CRLF)
		$Text = ""
		
    WEnd
	
EndIf	

Sleep(5000)
Exit
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Пример:

Код:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

$ClearProgress = 0
$processing = "Processing "
$progress = ""
Dim $spin[4] = ['¦', '/', '-', '\' ]


For $i = 1 To 30
    For $s = 1 To Ubound($spin)-1
		ConsoleWrite(@CR & $processing & $spin[$s])
		Sleep(50)
    Next
Next

ConsoleWrite(@CRLF & @CRLF & "DONE!")
Sleep(2000)

$ClearProgress = 0

$progress = ""

$processing = "Processing ["
$PaddedProgress = ""

For $i = 1 To 50
    $ProgressLength = StringLen($progress)
   
	For $iPad = 1 To 10 - $ProgressLength
		$PaddedProgress &= " "
    Next
	
    ConsoleWrite(@CR & $processing & $PaddedProgress & "]")
    Sleep(50)
	
    $ClearProgress += 1
    $progress &= "."
	
    If $ClearProgress = 11 Then
        ConsoleWrite(@CR & "                                                                     ")
		ConsoleWrite(@CR & "Processing.")
        $ClearProgress = 0
        $progress = ""
    EndIf
	
    $PaddedProgress = $progress
Next

$PaddedProgress = ".........."
ConsoleWrite(@CR & $processing & $PaddedProgress & "]")
ConsoleWrite(@CRLF & @CRLF & "DONE!")
Sleep(2000)



Добавлено:
Сообщение автоматически объединено:

Или с использованием функций от Erik Pilsits:

Код:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include "ConsoleProgress.au3"

For $i = 0 To 100 Step 10
    _ConsoleProgress($i)
    Sleep(400)
Next

ConsoleWrite(@CRLF)

For $i = 1 To 10
    _ConsoleProgress(Random(0, 100, 1), 40, "-", "O")
    Sleep(400)
Next

ConsoleWrite(@CRLF)

For $i = 100 To 0 Step -10
    _ConsoleProgress($i, 60, ".", "{")
    Sleep(400)
Next
 
Верх