我使用以下命令启动服务器:
$BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide, $STDERR_MERGED)
然后我从服务器获取数据(它在while循环中):
Assign("sOutput", StdoutRead($BungeeServer, False, False) & @CRLF)
GUICtrlSetData($Edit1, $sOutput)
问题是它只返回最新的信息字符串。我需要它来添加而不是替换值。有人知道一个简单的方法吗?
编辑:当服务器启动时,您通常会获得一个cmd窗口。我希望能够在Gui中拥有它。此外,我只想在单击按钮时显示它,它仍应在服务器启动时开始获取数据。文本行也在框外。我试过了:
Do
$msg1 = GUIGetMsg()
$line1 = StdoutRead($BungeeServer, True)
$totalOutput1 &= $line1 & @CRLF
GUICtrlSetData($Edit1, $totalOutput1)
$line2 = StdoutRead($1, True)
$totalOutput2 &= $line2 & @CRLF
GUICtrlSetData($Edit2, $totalOutput2)
$line3 = StdoutRead($2, True)
$totalOutput3 &= $line3 & @CRLF
Until $msg = $GUI_EVENT_CLOSE
编辑框是用:
制作的 $Form2 = GUICreate("Servers", @DesktopWidth - 15, @DesktopHeight - _GetTaskBarHeight() - 35, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
$Edit2 = GUICtrlCreateEdit("", 635, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
$Edit3 = GUICtrlCreateEdit("", 634 + 634, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
GUISetState(@SW_SHOW)
编辑:我找到了一个更好的方法,在我做了一个子窗口并且不需要所有其他东西的时候:
$GUI = GUICreate("Consoles", 1020, 600, 1282, 300, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
If GUICtrlRead($Bungee) = 1 Then
$BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide)
If Not ProcessWait($BungeeServer) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Bungee")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Bungee")
Global $hwnd0 = WinGetHandle("Bungee")
EndIf
EndIf
_WinAPI_SetWindowLong($hwnd0, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd0, $GUI)
WinMove($hwnd0, "", 0, 0, 340, 300)
仍需要找到一种方法将ControlSend用于子窗口:/
答案 0 :(得分:1)
使用StdoutRead($BungeeServer, True)
StdoutRead ( process_id [, peek = false [, binary = false]] )
peek [optional] If true the function does not remove the read characters from the stream.
OR
考虑在获取新数据之前存储先前的数据。您可以添加它,而不是将新数据分配给变量 例如。
$totalOutput &= $newOutput & @LF
关于StdoutRead
:为了获取所有数据,必须在循环中调用它。
从帮助文件中:
; Demonstrates StdoutRead()
#include <Constants.au3>
Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDOUT read:", $line)
WEnd
While 1
$line = StderrRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDERR read:", $line)
WEnd
MsgBox(0, "Debug", "Exiting...")
考虑到上述所有情况,StdoutRead
应该像这样使用:
Local $sOutput
While 1
$line = StdoutRead($foo, True)
If @error Then ExitLoop
$sOutput = $line
WEnd
OR
Local $sOutput
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$sOutput &= $line & @LF
WEnd