Schnitzel: Das stimmt so nicht! Wenn Du im OnEventMode per Button eine Funktion aufrufst, in der Du eine Endlos-Schleife laufen lässt, dann reagiert die GUI nicht auf weitere Events.
Es ist aber generell nicht nötig in der aufgerufenen Funktion diese Schleife laufen zu lassen. Man kann den Prozess mit Run starten und dann in der eigentlichen Schleife darauf reagieren:
Spoiler anzeigen
#include <AutoItConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$win = GUICreate("Script zur Sicherung durch robocopy - ver0.1", 640, 480, -1, -1)
GUICtrlCreateLabel("Live Ansincht", 10, 10, 710)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$btn_copy = GUICtrlCreateButton("copy", 220, 440, 75, 25)
$btn_exit = GUICtrlCreateButton("Exit", 400, 440, 75, 25)
$output_cmd = GUICtrlCreateEdit("", 10, 40, 620, 300, $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL)
$btn_cancel = GUICtrlCreateButton("Abbruch", 310, 440, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()
Global $robocopy
[/autoit] [autoit][/autoit] [autoit]While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $btn_exit, $GUI_EVENT_CLOSE
Exit
Case $btn_copy
GUICtrlSetState($btn_copy, $GUI_DISABLE)
GUICtrlSetState($btn_cancel, $GUI_SHOW)
$robocopy = Run(@ComSpec & " /c " & "ping 127.0.0.1", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Case $btn_cancel
GUICtrlSetState($btn_cancel, $GUI_HIDE)
GUICtrlSetState($btn_copy, $GUI_ENABLE)
ProcessClose($robocopy)
EndSwitch
If ProcessExists($robocopy) Then
$line = StdoutRead($robocopy)
GUICtrlSetData($output_cmd, $line, 1)
Else
If BitAND(GUICtrlGetState($btn_cancel), $GUI_SHOW) Then GUICtrlSetState($btn_cancel, $GUI_HIDE)
If BitAND(GUICtrlGetState($btn_copy), $GUI_DISABLE) Then GUICtrlSetState($btn_copy, $GUI_ENABLE)
EndIf
WEnd