Hallo
Vielen Dank an Bitnugger für Post #34
Die Funktion "jump to line" ist dort sehr gut erklärt.
Fand sonst kaum was darüber.
Gruß M.
Hallo
Vielen Dank an Bitnugger für Post #34
Die Funktion "jump to line" ist dort sehr gut erklärt.
Fand sonst kaum was darüber.
Gruß M.
Hallo
Habe mit der Suche diesen Thread gefunden da ich das gleiche Problem hatte.
Tooltips werden angezeigt, aben nur wenn nicht im "BalloonTip-Modus".
ZitatWarum auf einem PC der Balloon-Tip dargestellt wird und auf dem andren nicht kann ich nicht nachvollziehen. Die Voraussetzung (IE5 oder höher) ist gegeben.
und die Lösung ist:
Eine Windows Einstellung in der Registry:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurentVersion\Explorer\Advanced
Werte setzen und evtl. Neustart.
EnableBalloonTips -> 1
ShowInfoTip -> 1
Hier detailierte Infos.
Gruß M.
Hallo Schnuffel
Dein Script läuft!
Werde heute weitere Tests machen, bis dahin sag´ich Vielen Dank und Gute Nacht.
Gruß M.
Hallo Community
Die Lösung funktioniert zwar, doch sobald man in das "EDIT-Feld" klickt ist es vorbei mit dem "Auto-Scroll".
Das gilt auch wenn das "EDIT-Feld" disabled war.
Verbesserte Version:
; AutoIt Version: 3.3.0.0
[/autoit] [autoit][/autoit] [autoit]Opt("WinWaitDelay", 500)
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
#include <Process.au3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$orange = "0xFF6600"
$green = "0x66FF33"
$yellow = "0xFFFF00"
$kin = "0xFF9966"
$turquoise = "0x00CCCC"
$magenta = "0xCC6699"
$lgreen = "0xCCFFCC"
$Form1 = GUICreate("CMD - GUI", 736, 748, 52, 44)
$Group1 = GUICtrlCreateGroup("", 16, 8, 697, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("cmd", 16, 72, 337, 129)
$Label1 = GUICtrlCreateLabel("File", 32, 96, 60, 17)
$Input1 = GUICtrlCreateInput("", 104, 93, 233, 21)
GUICtrlSetData($Input1, "ping.exe")
$Label2 = GUICtrlCreateLabel("Count", 32, 136, 60, 17)
$Input2 = GUICtrlCreateInput("", 104, 133, 233, 21)
GUICtrlSetData($Input2, "19")
$Label3 = GUICtrlCreateLabel("Address", 32, 176, 60, 17)
$Input3 = GUICtrlCreateInput("", 104, 173, 233, 21)
GUICtrlSetData($Input3, "127.0.0.1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 376, 72, 337, 129)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("", 16, 320, 697, 369)
$Button1 = GUICtrlCreateButton("START", 40, 704, 75, 25)
$Button2 = GUICtrlCreateButton("EXIT", 608, 704, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 40, 344, 649, 329)
GUICtrlSetData(-1, "")
GuiCtrlSetBkColor(-1, $lgreen)
;GUICtrlSetState($Edit1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("", 16, 208, 697, 105)
$Label4 = GUICtrlCreateLabel("Command", 32, 232, 100, 17)
$Input4 = GUICtrlCreateInput("", 144, 229, 553, 21)
$Label5 = GUICtrlCreateLabel("", 32, 272, 100, 17)
$Input5 = GUICtrlCreateInput("", 144, 269, 553, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$show = GUISetState(@SW_SHOW) ; startet die GUI
Local $batch, $command,$winTitle
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
#cs
Case $Button1
GuiCtrlSetBkColor($Button1, $orange)
$command = GUICtrlRead($Input1) & " -n " & GUICtrlRead($Input2) & " " & GUICtrlRead($Input3)
GUICtrlSetData($Edit1,_getDOSOutput($command))
GuiCtrlSetBkColor($Button1, $green)
#ce
; #cs
Case $Button1
GuiCtrlSetBkColor($Button1, $orange)
$command = GUICtrlRead($Input1) & " -n " & GUICtrlRead($Input2) & " " & GUICtrlRead($Input3)
GUICtrlSetData($Input4, $command)
Local $text = ''
Local $Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If @error Then ExitLoop
Sleep(500)
GUICtrlSetData($Edit1,$text)
GUICtrlSetState($Edit1, $GUI_FOCUS)
Send("{END}")
WEnd
GuiCtrlSetBkColor($Button1, $green)
; #ce
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
Exit
EndSwitch
WEnd
;#cs
Func _getDOSOutput($command)
Local $text = ''
Local $Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If @error Then ExitLoop
Sleep(10)
WEnd
Return $text
EndFunc ;==>_getDOSOutput
;#ce
Wie könnte man diesen Umstand umgehen ?
Gruß M.
Hallo Micha_he
Vielen Dank für Deine Antwort, hat genau gepasst.
[autoit]GUICtrlSetState($Edit1, $GUI_FOCUS)
[/autoit]- muß drinstehen, sonst springt die Zeile nicht weiter.
Danke und Gruß M.
Hallo Community
In einer GUI soll ein DOS-Befehlsablauf per StdoutRead dargestellt werden.
Dazu hab ich die "_getDOSOutput"-Function abgewandelt um jeweils den aktuellen Stand der DOS-Ausgabe abzufragen.
Beispiel mit ping:
; AutoIt Version: 3.3.0.0
[/autoit] [autoit][/autoit] [autoit]Opt("WinWaitDelay", 500)
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
#include <Process.au3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$orange = "0xFF6600"
$green = "0x66FF33"
$yellow = "0xFFFF00"
$kin = "0xFF9966"
$turquoise = "0x00CCCC"
$magenta = "0xCC6699"
$lgreen = "0xCCFFCC"
$Form1 = GUICreate("CMD - GUI", 736, 748, 52, 44)
$Group1 = GUICtrlCreateGroup("", 16, 8, 697, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("cmd", 16, 72, 337, 129)
$Label1 = GUICtrlCreateLabel("File", 32, 96, 60, 17)
$Input1 = GUICtrlCreateInput("", 104, 93, 233, 21)
GUICtrlSetData($Input1, "ping.exe")
$Label2 = GUICtrlCreateLabel("Count", 32, 136, 60, 17)
$Input2 = GUICtrlCreateInput("", 104, 133, 233, 21)
GUICtrlSetData($Input2, "19")
$Label3 = GUICtrlCreateLabel("Address", 32, 176, 60, 17)
$Input3 = GUICtrlCreateInput("", 104, 173, 233, 21)
GUICtrlSetData($Input3, "127.0.0.1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 376, 72, 337, 129)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("", 16, 320, 697, 369)
$Button1 = GUICtrlCreateButton("START", 40, 704, 75, 25)
$Button2 = GUICtrlCreateButton("EXIT", 608, 704, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 40, 344, 649, 329)
GUICtrlSetData(-1, "")
GuiCtrlSetBkColor(-1, $lgreen)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("", 16, 208, 697, 105)
$Label4 = GUICtrlCreateLabel("Command", 32, 232, 100, 17)
$Input4 = GUICtrlCreateInput("", 144, 229, 553, 21)
$Label5 = GUICtrlCreateLabel("", 32, 272, 100, 17)
$Input5 = GUICtrlCreateInput("", 144, 269, 553, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$show = GUISetState(@SW_SHOW) ; startet die GUI
Local $batch, $command,$winTitle
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
#cs
Case $Button1
GuiCtrlSetBkColor($Button1, $orange)
$command = GUICtrlRead($Input1) & " -n " & GUICtrlRead($Input2) & " " & GUICtrlRead($Input3)
GUICtrlSetData($Edit1,_getDOSOutput($command))
GuiCtrlSetBkColor($Button1, $green)
#ce
; #cs
Case $Button1
GuiCtrlSetBkColor($Button1, $orange)
$command = GUICtrlRead($Input1) & " -n " & GUICtrlRead($Input2) & " " & GUICtrlRead($Input3)
GUICtrlSetData($Input4, $command)
Local $text = ''
Local $Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If @error Then ExitLoop
Sleep(500)
GUICtrlSetData($Edit1,$text)
WEnd
GuiCtrlSetBkColor($Button1, $green)
; #ce
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
Exit
EndSwitch
WEnd
;#cs
Func _getDOSOutput($command)
Local $text = ''
Local $Pid = Run(@ComSpec & ' /c ' & $command, '', @SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If @error Then ExitLoop
Sleep(10)
WEnd
Return $text
EndFunc ;==>_getDOSOutput
;#ce
(Wenn man die Function "_getDOSOutput" selbst verwendet, wird erst nach beenden des Befehls die Ausgabe dargestellt.)
Leider scrollt in obigem Script das "EDIT-Feld" aber nicht von selbst.
Wie könnte man das Script erweitern um immer die neueste Ausgabezeile angezeigt zu bekommen ?
Gruß M.
Hallo Tweaky
Formeller Fehler im Index der DE-Hilfe:
Der original-Eintrag -
ZitatAlles anzeigenSwitch <expression>
Case <value> [To <value>] [,<value> [To <value>] ...]
statement1
...
[Case <value> [To <value>] [,<value> [To <value>] ...]
statement2
...]
[Case Else
statementN
...]
EndSwitch
wurde nicht korrekt übernommen -
ZitatAlles anzeigenSwitch
Case [To ] [, [To ] ...]
statement1
...
[Case [To ] [, [To ] ...]
statement2
...]
[Case Else
statementN
...]
EndSwitch
Bitte nimm´s nicht persönlich
Gruß M.
Hi OneNonlyNova
Probiert hab ich´s schon, aber ohne Erfolg.
Trotzdem, ich bleib dran.
Gruß M.
Hi AutoBert
Vielen Dank für Deine Bemühungen, Du hast Dich ja echt reingehängt.
Ich hab Dein Update gerade übertragen aber dennoch wird nur CMD-Befehl mitsamt Deiner neuen Schlußmeldung ausgeführt.
Der Fortschrittsbalken zeigt sich nicht und auch die Prozente bleiben auf Null.
Damit Du es selbst testen kannst hab ich hier das Script:
autoit.de/wcf/attachment/4249/
und hier die dazugehörige Batch-Datei "exec.bat",
@Echo off
Title MKISOFS - creating image . . .
color 1E
MKISOFS.exe -volid TEST-090401 -iso-level 4 -duplicates-once -o "C:\TEST.iso" "C:\TEMP"
- die zusammen mit mkisofs.exe MD5=(cc9d20cc7aca844a99f8e11e94a94d60) und dem Script in einem Ordner gespeichert sein müssen.
Hab grad bemerkt daß die Version in den neuesten cdrtools "-duplicates-once" nicht (mehr) unterstützt, deshalb obige Version verwenden.
Dann erstell einen Ordner C:\Temp in dem Du wiederum einen Ordner zb "C:\TEMP\SUB" mit ca.100mb Dateien Deiner Wahl erstellst.
Mach einen ersten Test mit dem Script: ISO ist so groß wie der Ordner C:\TEMP.
Mach dann eine Kopie von "C:\TEMP\SUB" => "C:\TEMP\Kopie von SUB", und wieder ein neues ISO.
ISO ist nur halb so groß wie der Ordner C:\TEMP.
Danke für Deinen Hinweis auf $GUI_HIDE.
Interressant ist auch der ExitCode: "Exit($ToDo*-1)".
-Kann man das
[autoit]$delete = FileExists($outfile)
If $delete = 1 Then ; file exists
$fs = "YES"
Else
$fs = "NO"
EndIf
in eine eigene Funktion auslagern ?
Gruß M.
Hallo Raupi
Prima, , Danke für Deinen Rat.
Gruß M.
Hallo Community
Ich steh vor einem Rätsel.
In manchen GUIs lassen sich die Controls verstecken, warum nicht in diesem:
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <Process.au3>
#include <File.au3>
$exe = "CMD.EXE"
$indir = "C:\TEMP"
$outfile = "C:\TEST.ISO"
$fsinmb = "5000"
$savdrv = "C:"
$fspace = 10000
$isofertig = 4900
Example()
Local $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID ;
Sleep(5000)
Func Example()
Local $progressbar1, $button, $wait, $s, $msg, $m, $percent, $outsizeupd, $fs, $wtwf, $PID, $elc, $aved, $aved2, $GUI_HIDE
$PID = ProcessExists($exe)
;----------------------------------------
$delete = FileExists($outfile)
If $delete = 1 Then ; file exists
$fs = "YES"
$elc = "0x66FF33"
Else
$fs = "NO"
$elc = "0xFF0000"
EndIf
;----------------------------------------
GUICreate("MKISOFS - PreMastering - 90330", 660, 260, 50, 500) ; erstellt GUI-Fenster so groß wie DOS-Box
$button = GUICtrlCreateButton("START", 20, 210, 80, 30) ; erstellt START-Button ; ID = 3
GUICtrlSetState (-1, $GUI_HIDE)
GUICtrlSetState (3, $GUI_HIDE)
GuiCtrlSetBkColor(-1, 0xFFFF00) ; gelb
GUICtrlCreateLabel("Input: ", 20, 15) ; ID = 4
GUICtrlSetState (-1, $GUI_HIDE)
GUICtrlCreateInput($indir, 60, 13, 350, 15) ; ID = 5
GUICtrlSetState (-1, $GUI_HIDE)
GUICtrlCreateLabel("Output: ", 20, 45) ; ID = 6
GUICtrlSetState (-1, $GUI_HIDE)
GUICtrlCreateInput($outfile, 60, 43, 350, 15) ; ID = 7
GUICtrlCreateLabel("File exists: ", 560, 45) ; ID = 8
GUICtrlCreateInput($fs, 615, 43, 30, 15) ; ID = 9
GuiCtrlSetBkColor(9, $elc)
$progressbar1 = GUICtrlCreateProgress(10, 80, 640, 20) ; ID = 10 ; Fortschrittsbalken
GUISetState(@SW_SHOW) ; startet die GUI
$m = GUIGetMsg()
If $msg = $button Then GUICtrlSetState (-1, $GUI_HIDE)
EndFunc ;==>Example
Kann ich diese Abfrage als Funktion formulieren:
$delete = FileExists($outfile)
If $delete = 1 Then ; file exists
$fs = "YES"
$elc = "0x66FF33"
Else
$fs = "NO"
$elc = "0xFF0000"
EndIf
Bin dankbar für jeden Hinweis.
Gruß M.
Hi AutoBert
Vielen Dank für Deinen Hinweis.
Das DEMO-Script rattert zwar durch, aber in echt läuft das Script nicht.
Wahrscheinlich weil $percent mit Null beginnen muß.
Zur Kontrolle poste ich den Script mal als UNVOLLSTÄNDIG.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=MKISOFS.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; AutoIt Version: 3.3
; Template Version: 90129
Opt("WinWaitDelay", 500)
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <Process.au3>
#include <File.au3>
Opt('MustDeclareVars', 1)
Local $test, $size, $result, $fin, $log, $outfile, $savdrv, $outfile, $batch
Local $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID ;
;$indir = "S:\SYSTEM\CUSTOM-WPI"
;$outfile = "D:\GRUB.iso"
;$command = "mkisofs.exe -o " & $outfile & " " & $indir & ""
$exe = "MKISOFS.exe"
;FileDelete($outfile)
;$delete = FileExists($outfile)
;$outfile = "" & $file & ""
; MsgBox(0 , "Info", " $outfile = " & $outfile & "")
$delete = FileExists($outfile)
; MsgBox(48 , "Info", " FileExists = " & $outfile & "")
FileDelete($outfile)
$delete = FileExists($outfile)
$exe = "mkisofs.exe"
$indir = "C:\Temp"
$outfile = "C:\TEST.ISO"
$savdrv = "C:"
$batch = "D:\OWNERFILES\AKTUELL\AUTOIT\MKISO_GUI\MKISOFS\exec.bat"
$isofertig = DirGetSize($indir) ;kb
$fsinmb = Round ($isofertig / 1024 / 1024, 2)
$space = DriveSpaceFree( $savdrv )
; MsgBox(0 , "Info", " $space = " & $space & "")
$fspace = Round ($space, 2)
; MsgBox(0 , "Info", " $fspace = " & $fspace & "")
; MsgBox(0 , "Info", "Estimated Filesize = " & $isofertig & " kb")
; MsgBox(0 , "Info", "Estimated Filesize = " & $fsinmb & " MB")
$isoaktuell = 0
Global $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID, $i;
Global $progressbar1, $button, $wait, $s, $msg, $m, $percent, $outsizeupd, $fs, $wtwf, $PID, $elc, $ToDo, $outfile, $batch
Example()
;__________________________________________________________________________________________
Func Example()
; Local $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID ;
; MsgBox(0 , "Info", " $savdrv = " & $savdrv & "")
$PID = ProcessExists($exe)
$delete = FileExists($outfile)
If $delete = 1 Then ; file exists
$fs = "YES"
Else
$fs = "NO"
EndIf
; GUICreate("MKISOFS - PreMastering - 90327", 660, 160, 50, 500) ; erstellt GUI-Fenster so groß wie DOS-Box
GUICreate("MKISOFS - PreMastering - 90327", 660, 160, 50, 500) ; erstellt GUI-Fenster so groß wie DOS-Box
$progressbar1 = GUICtrlCreateProgress(10, 45, 640, 20); Fortschrittsbalken
$button = GUICtrlCreateButton("START", 20, 110, 80, 30) ; erstellt START-Button ; ID = 4
GuiCtrlSetBkColor(-1, 0xFFFF00)
GUICtrlCreateLabel("Source: " & $indir & "", 20, 15) ; ID = 5
GUICtrlCreateLabel("File: " & $outfile & "", 20, 80) ; ID = 6
GUICtrlCreateLabel("File exists: " & $fs & "", 450, 80) ; ID = 7
GUICtrlCreateLabel("Size: " & $fsinmb & " MB", 300, 105) ; ID = 8
GUICtrlCreateLabel("Output: 0 MB", 288, 130) ; ID = 9
GUICtrlCreateLabel("Progress: 0 %", 135, 105) ; ID = 13
GUICtrlCreateLabel("Free Space on " & $savdrv & "\ = " & $fspace & " MB", 450 , 105) ; ID = 80
GuiCtrlSetBkColor(-1, 0x00CCCC)
GUISetState(@SW_SHOW) ; startet die GUI
$wait = 10000 ; time in msec to next loop-step
$percent = 0
GUICtrlSetData($progressbar1, $percent) ; gibt die Position des Balkens vor
$ToDo = 101 ; noch nicht angefangen
Do ; Anfang der Schleife (= Anfang der progresssteps ?)
$msg = GUIGetMsg() ; fragt ob, und was geklickt wurde
If $msg = $button And GUICtrlRead($Button) = "START" Then ; wenn button-click START
Run(@ComSpec & " /c " & $batch & "", $indir)
WinWait("C:\WINDOWS\system32\cmd.exe")
WinMove("C:\WINDOWS\system32\cmd.exe", "", 50, 100)
GUICtrlSetData($button, "CANCEL"); ändert label des button in CANCEL
GuiCtrlSetBkColor(4, 0xFF6600)
$msg = 0
$ToDo = 100 ;angefangen
EndIf
If $msg = $button And GUICtrlRead($Button) = "CANCEL" Then $ToDo = -1; abbrechen
if $msg = $GUI_EVENT_CLOSE Then $ToDo = -1; auch abbrechen
;ConsoleWrite("DO-Schleife: "&$ToDo & @CRLF)
If $ToDo <101 and $ToDo >0 Then ; wenn angefangen und nicht abgebrochen wurde ----------?---------
if Not ProcessExists($exe) Then $ToDo =-1 ; auch abbrechen Prozess existiert nicht (mehr?)
if $ToDo >0 Then _writePercentDEMO() ; startet Func _writePercentDEMO()
EndIf
Until $ToDo <= 0; bis fertig
If ProcessExists($exe) Then ProcessClose($exe) ; beende CMD
Sleep(2000)
EndFunc ;==>Example
Func _writePercentDEMO()
$ToDo = $percent-100 ; startet mit 99 ? ----------?---------
;ConsoleWrite("FUNC: "&$ToDo & @CRLF)
$i = 100 - $ToDo ; startet mit 99 ? ----------?---------
$space = DriveSpaceFree( $savdrv ) ; prüft freien speicherplatz
$fspace = Round ($space, 2) ; rundet die zahl auf 2 stellen hinterm komma
$isoaktuell = FileGetSize($outfile); prüft Dateigröße in kb
$outsizeupd = Round ($isoaktuell / 1024 / 1024, 2); prüft Dateigröße in MB
$percent = Round($isoaktuell/$isofertig*100) ; errechnet prozentwert
GUICtrlSetData($progressbar1, $percent) ; gibt die Position des Balkens vor
;die Labels sollten eigentlich mit GuiCtrlSetState geändert werden und nicht jedesmal neu erzeugt ----------?---------
GuiCtrlCreateLabel("File exists: " & $fs & "", 450, 80)
; GuiCtrlSetBkColor(-1, $elc)
GUICtrlCreateLabel("Progress: " & $percent & " %", 135, 105)
GUICtrlCreateLabel("Output: " & $percent & " kb", 289, 130)
GUICtrlCreateLabel("Free Space on " & $savdrv & "\ = " & $fspace & " MB", 450 , 105)
GuiCtrlSetBkColor(-1, 0x00CCCC)
GUICtrlCreateLabel(" cmd.exe PID = " & $PID & "", 450, 130) ; ID = 16
GuiCtrlSetBkColor(-1, 0xFF9966)
GUICtrlCreateLabel("Step Nr. = " & $i & "" , 400, 15) ; ID = 16
Sleep($wait) ; wartet vorgegebene Zeit
EndFunc
Was mich aber viel weiter gebracht hat war Dein Tip mit dem "GUICtrlSetData".
Zur Lösung der Exit-Strategiie mußte ich 3 Zeilen einfügen:
[autoit]$PID = ProcessExists($exe)
If $PID < 1 Then $i = 100
...
If $i > 100 Or $PID = 0 Then
Ende gut alles gut . . .
Besten Dank und Gruß - M.
Hallo AutoBert
Vielen herzlichen Dank für Dein Script.
Ich habs so verstanden:
Die gesamte Prozentwertbestimmung wird in eine eigene Funktion ausgelagert ?
Da läuft ein Countdown bis der Progress fertig ist, und dann wird das Script beendet.
Das funktioniert gut.
"die Labels sollten eigentlich mit GuiCtrlSetState geändert werden"
- Kannst Du dafür bitte noch ein Beispiel posten.
Gruß M.
Hallo Community
Habe folgendes Script für die ISO-Erstellung konzipiert:
DEMO-Script:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=MKISOFS.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; AutoIt Version: 3.3
; Template Version: 90129
Opt("WinWaitDelay", 500)
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <Process.au3>
#include <File.au3>
$exe = "CMD.EXE"
$indir = "C:\TEST"
$outfile = "C:\TEST.ISO"
$fsinmb = "5000"
$savdrv = "C:"
$fspace = 10000
$isofertig = 4900
Example()
Local $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID ;
;__________________________________________________________________________________________
Func Example()
; Local $outfile, $isofertig, $isoaktuell, $command, $exe, $delete, $indir, $fsinmb, $space, $savdrv, $fspace, $PID ;
Local $progressbar1, $button, $wait, $s, $msg, $m, $percent, $outsizeupd, $fs, $wtwf, $PID, $elc
; MsgBox(0 , "Info", " $savdrv = " & $savdrv & "")
$PID = ProcessExists($exe)
$delete = FileExists($outfile)
If $delete = 1 Then ; file exists
$fs = "YES"
Else
$fs = "NO"
EndIf
GUICreate("MKISOFS - PreMastering - 90327", 660, 160, 50, 500) ; erstellt GUI-Fenster so groß wie DOS-Box
$progressbar1 = GUICtrlCreateProgress(10, 45, 640, 20); Fortschrittsbalken
$button = GUICtrlCreateButton("START", 20, 110, 80, 30) ; erstellt START-Button ; ID = 4
GuiCtrlSetBkColor(-1, 0xFFFF00)
GUICtrlCreateLabel("Source: " & $indir & "", 20, 15) ; ID = 5
GUICtrlCreateLabel("File: " & $outfile & "", 20, 80) ; ID = 6
GUICtrlCreateLabel("File exists: " & $fs & "", 450, 80) ; ID = 7
GUICtrlCreateLabel("Size: " & $fsinmb & " MB", 300, 105) ; ID = 8
GUICtrlCreateLabel("Output: 0 MB", 288, 130) ; ID = 9
GUICtrlCreateLabel("Progress: 0 %", 135, 105) ; ID = 13
GUICtrlCreateLabel("Free Space on " & $savdrv & "\ = " & $fspace & " MB", 450 , 105) ; ID = 80
GuiCtrlSetBkColor(-1, 0x00CCCC)
GUISetState(@SW_SHOW) ; startet die GUI
$wait = 100 ; time in msec to next loop-step
Do ; Anfang der Schleife (= Anfang der progresssteps ?)
$msg = GUIGetMsg() ; fragt ob, und was geklickt wurde
If $msg = $button And GUICtrlRead($Button) <> "DONE" Then ; wenn button-click START
Run(@ComSpec)
WinWait("C:\WINDOWS\system32\cmd.exe")
WinMove("C:\WINDOWS\system32\cmd.exe", "", 50, 100)
GUICtrlSetData($button, "CANCEL"); ändert label des button in CANCEL
GuiCtrlSetBkColor(4, 0xFF6600)
For $i = 0 To 100 ; Schritte von 0 bis 100
$m = GUIGetMsg() ; fragt ob, und was geklickt wurde
If $m = -3 Then ExitLoop ; ???
If $m = $button Then ; wenn button-click CANCEL
ProcessClose($exe) ; beendet CMD
Exit ; beendet dieses Script
Else ; wenn button-click CANCEL nicht erfolgt
$delete = FileExists($outfile)
If $delete = 1 Then ; file exists then set electioncolor ($elc)
$fs = "YES"
$elc = "0x66FF33"
Else
$fs = "NO"
$elc = "0xFF0000"
EndIf
$PID = ProcessExists($exe)
$space = DriveSpaceFree( $savdrv )
$fspace = Round ($space, 2)
$isoaktuell = 950 + $i*40; prüft Dateigröße in kb
$outsizeupd = Round ($isoaktuell / 1024 / 1024, 2); prüft Dateigröße in MB
GUICtrlSetData($progressbar1, $isoaktuell/$isofertig*100) ; gibt die Position des Balkens vor
$percent = Round($isoaktuell/$isofertig*100)
GUICtrlCreateLabel("File exists: " & $fs & "", 450, 80)
GuiCtrlSetBkColor(-1, $elc)
GUICtrlCreateLabel("Progress: " & $percent & " %", 135, 105)
GUICtrlCreateLabel("Output: " & $percent & " kb", 289, 130)
GUICtrlCreateLabel("Free Space on " & $savdrv & "\ = " & $fspace & " MB", 450 , 105)
GuiCtrlSetBkColor(-1, 0x00CCCC)
GUICtrlCreateLabel(" cmd.exe PID = " & $PID & "", 450, 130) ; ID = 16
GuiCtrlSetBkColor(-1, 0xFF9966)
GUICtrlCreateLabel("Step Nr. = " & $i & "" , 400, 15) ; ID = 16
Sleep($wait) ; wartet vorgegebene Zeit
; $i = $percent
EndIf ; Ende der Bedingung
Next ; Weiter geht´s
#cs
If $i > 45 And $PID < 1 Then
GUICtrlSetData($button, "DONE"); ändert label des button in DONE
GuiCtrlSetBkColor(4, 0xFFFF00)
GUICtrlCreateLabel("Process finished.", 135, 130)
GuiCtrlSetBkColor(-1, 0x66FF33)
#ce
If $i > 100 Then
GUICtrlSetData($button, "DONE"); ändert label des button in DONE
GuiCtrlSetBkColor(4, 0xFFFF00)
GUICtrlCreateLabel("Process finished.", 135, 130)
GuiCtrlSetBkColor(-1, 0x66FF33)
EndIf ; Ende der Bedingung
ElseIf $msg = $button And GUICtrlRead($Button) = "CANCEL" Then
$msg = $GUI_EVENT_CLOSE
ElseIf $msg = $button And GUICtrlRead($Button) = "DONE" Then
ProcessClose($exe) ; beendet CMD
$msg = $GUI_EVENT_CLOSE
EndIf ; Ende der Bedingung
Until $msg = $GUI_EVENT_CLOSE ; bis Fenster geschlossen wird
EndFunc ;==>Example
;__________________________________________________________________________________________
Um mein Problem für Euch nachvollziehbar zu machen hab ich im "DEMO-Script" den eigentlichen Befehl durch ein blankes CMD-Fenster ersetzt.
- Wenn das Script gestartet wird bewegt sich der Fortschrittsbalken.
- Berechnet wird der Progress duch das Verhältnis von Source-Ordner zu fertiger Dateigröße. Wird im DEMO-Script natürlich nur simuliert.
Jetzt kommt im ECHTEN Script der Haken:
- mkisofs "spart" bis zu 15% Dateigröße durch Optimierung ein.
Dadurch bleibt der Progress, nach beenden von mkisofs, schon bei 85% stehen während das Script weiterarbeiten will.
Es lässt sich dann nicht mehr mit den GUI-Controls beenden, was denn wie ein Absturz des Programms wirkt.
- Ich wollte dann eine Formel einbauen, die im Falle von $PID = 0 dem Script suggeriert hätte daß $percent = 100 und somit das Ziel erreicht sei.
Da bin ich nicht mehr weitergekommen. Nach ZIGGG Versuchen muß ich Euch um Hilfe in der Angelegenheit bitten.
Bitte zeigt mir mit welchen Code-Zeilen ich die Möglichkeit hab, nach Beendigung von "mkisofs.exe" die Schleife zu beenden und den Prozentwert auf 100 zu setzen.
- Natürlich ist auch jede andere Problemlösung willkommen !
Gruß M.
PS. Wenn man wärend Ablauf des Scripts das CMD-Fenster schließt springt $PID zwar auf Null, aber im Hintergrund bleibt die letzte Ziffer der CMD.EXE-PID sichtbar.
- Wie kann man das korrigieren ?
Hallo Übersetzer
Vielen Dank für Euren Einsatz.
Die Hilfe hat sich ja bestens entwickelt.
Habe folgenden formellen Fehler im Index der DE-Hilfe gefunden:
ZitatFor...To...Step...Next
Schleife, die auf einem Ausdruck basiert.
For = To [Step ]
statements
...
Next
Im original sind die Parameter noch angegeben :
ZitatFor <variable> = <start> To <stop> [Step <stepval>]
statements
...
Next
Gruß M.
@MatthiasG
Vielen Dank für Dein og. Beispiel, mal schaun wie man´s verwenden kann.
Raupi
Besten Dank für Deine Korrekturen.
Genau das hat im Script gefehlt.
Danke, M.
Hallo MatthiasG.
Danke für Deine Antwort.
Tut mir leid, aber ich kann mir nicht vorstellen wie "GUICtrlRead" im Script eingefügt werden müßte.
Ich hab den Original-Script (Danke an den Autor) modifiziert damit er nachvollziehbar ist:
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $progressbar1, $button, $wait, $s, $msg, $m
GUICreate("Stop My GUI", 500, 100, 100, 200)
$progressbar1 = GUICtrlCreateProgress(10, 10, 480, 20); Fortschrittsbalken
$button = GUICtrlCreateButton("Start", 60, 50, 80, 30)
GUISetState()
$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
Do
$msg = GUIGetMsg()
If $msg = $button Then ; wenn button-click
GUICtrlSetData($button, "Stop"); ändert status des button
For $i = $s To 100
$m = GUIGetMsg()
If $m = -3 Then ExitLoop
If $m = $button Then
GUICtrlSetData($button, "Weiter")
$s = $i;save the current bar-position to $s
ExitLoop
Else
$s = 0
GUICtrlSetData($progressbar1, $i)
Sleep($wait)
EndIf
Next
If $i > 100 Then
GUICtrlSetData($button, "FINISHED"); ändert label des button in FINISHED
If $m = $button Then ; wenn button-click FINISHED --- -->
Exit ; dann soll das Script beendet werden --> aber ??? progress startet neu !!! WARUM ?
EndIf
EndIf
EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Wenn es eine Möglichkeit gibt, mit Klick auf FINISH das Script zu beenden, bitte ich um Korrektur des Scripts.
Danke
Gruß M.