Hey Leute,
ich hoffe der Titel ist nicht allzu daneben. Mir ist leider kein besserer eingefallen.
Ich habe ein Programm, dass an einer Stelle mit Hilfe von wget.exe Datei(en) herunterlädt.
Aus kosmetischen (CMD Window nicht so "hübsch") und praktischen Gründen (wenn es keine neuere Datei gibt, ist das CMD so schnell wieder geschlossen, dass man nicht checkt was geht) lasse ich den Output in der GUI anzeigen.
In der Kommandozeile sieht das bei wget so aus:
Spoiler anzeigen
--2014-05-11 20:10:07-- http://www.speedtest.qsc.de/100MB.qsc
Resolving www.speedtest.qsc.de... 195.90.7.115
Connecting to www.speedtest.qsc.de|195.90.7.115|:80... connected.
HTTP request sent, awaiting response... 200 OKLength: 104857600 (100M)Saving to: `100MB.qsc'
100%[======================================>] 104,857,600 3.07M/s in 34s
2014-05-11 20:10:41 (2.95 MB/s) - `100MB.qsc' saved [104857600/104857600]
Im StderrRead (das Programm schreibt Messages nicht zu Stdout sondern zu Stderr) sieht es hingegen so aus
Spoiler anzeigen
.
.
.
.
9700K .......... .......... .......... .......... .......... 95% 3.15M 0s
9750K .......... .......... .......... .......... .......... 95% 2.41M 0s
9800K .......... .......... .......... .......... .......... 96% 2.34M 0s
9850K .......... .......... .......... .......... .......... 96% 1.42M 0s
9900K .......... .......... .......... .......... .......... 97% 1.89M 0s
9950K .......... .......... .......... .......... .......... 97% 2.29M 0s
10000K .......... .......... .......... .......... .......... 98% 2.11M 0s
10050K .......... .......... .......... .......... .......... 98% 2.51M 0s
10100K .......... .......... .......... .......... .......... 99% 2.61M 0s
10150K .......... .......... .......... .......... .......... 99% 1.93M 0s
10200K .......... .......... .......... .......... 100% 2.55M=4.7s
2014-05-11 20:12:59 (2.14 MB/s) - `10MB.qsc' saved [10485760/10485760]
Alles anzeigen
Dadurch musste ich schon das Limit der EditControl anpassen. Ein bar- Progress wie im Original wäre mir aber lieber.
Das Handbuch sagt dazu:
‘--progress=type’
Select the type of the progress indicator you wish to use. Legal indicators are “dot” and “bar”.
The “bar” indicator is used by default. It draws an ASCII progress bar graphics (a.k.a “thermometer” display) indicating the status of retrieval. If the output is not a TTY, the “dot” bar will be used by default.
Use ‘--progress=dot’ to switch to the “dot” display. It traces the retrieval by printing dots on the screen, each dot representing a fixed amount of downloaded data.
When using the dotted retrieval, you may also set the style by specifying the type as ‘dot:style’. Different styles assign different meaning to one dot. With the default style each dot represents 1K, there are ten dots in a cluster and 50 dots in a line. The binary style has a more “computer”-like orientation—8K dots, 16-dots clusters and 48 dots per line (which makes for 384K lines). The mega style is suitable for downloading large files—each dot represents 64K retrieved, there are eight dots in a cluster, and 48 dots on each line (so each line contains 3M). If mega is not enough then you can use the giga style—each dot represents 1M retrieved, there are eight dots in a cluster, and 32 dots on each line (so each line contains 32M).
Note that you can set the default style using the progress command in .wgetrc. That setting may be overridden from the command line. The exception is that, when the output is not a TTY, the “dot” progress will be favored over “bar”. To force the bar output, use ‘--progress=bar:force’.
Also --progress=bar:force
So weit so gut...
aber
dann schreibt es die Bar sehr weit in die Breite und dann irgendwann in der nächsten Zeile fort
Ich weiß (noch) nicht, wie ich die Punkte verwenden könnte um eine GUI-Progress-Bar darzustellen. Das würde aber auch nur bedingt weiterhelfen, da mir dann Meldungen wie "saved" "fully retrieved" oder "not newer nothing to do" entgehen. Ausserdem würde das dann massiven Einsatz von StringInString oder StringRegEx bedürfen und da bin ich gerade nicht fit genug drin.
Hat noch jemand eine Idee oder einen Tipp?
P.S. Hier der Quellcode für die Passage
Spoiler anzeigen
#include <GuiConstants.au3>
#include <ColorConstantS.au3>
#include <Constants.au3>
GuiCreate("STDIO Window", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$cID_Output = GuiCtrlCreateEdit("", 0, 10, 423, 260, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetLimit(-1, 0xF423F)
GUICtrlSetBkColor(-1, $COLOR_Black)
GUICtrlSetColor(-1, $COLOR_WHITE)
_readTest()
Sleep(10000)
Func _readTest()
Local $iPID = Run(@ComSpec & " /c .\wget.exe --progress=bar:force -N -c http://www.speedtest.qsc.de/10MB.qsc", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $sOutput = ""
While 1
$sErrOutput = StderrRead($iPID)
If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
ExitLoop
EndIf
GUICtrlSetData($cID_Output, $sErrOutput, 1)
WEnd
EndFunc