0

我正在尝试制作一个可以启动和停止多个服务器的 GUI 菜单。此外,它应该能够通过复选框和手动命令添加(例如“玩家名”)向具有不同参数的服务器发送命令。我需要的是找到一种让信息菜单工作的方法(它正在等待我认为的按钮),并找到一种将命令发送到打开的三个命令提示符的方法。我仍将添加两个服务器和一个蹦极服务器,但如果它与三个一起工作,它与六个一起工作。

Func Hub_func()
    Run(@ComSpec & " /C Java -Xmx1024M -jar spigot-1.6.2-R0.1.jar", "E:\Spill\Alle spill\Minecraft\Bungee Servers\Hub")
    Run(@ComSpec & " /C Java -Xmx1024M -jar spigot-1.6.2-R0.1.jar", "E:\Spill\Alle spill\Minecraft\Bungee Servers\Survival")
    Run(@ComSpec & " /C Java -Xmx1024M -jar spigot-1.6.2-R0.1.jar", "E:\Spill\Alle spill\Minecraft\Bungee Servers\Plotworld")
EndFunc   ;==>Hub_func
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <StaticConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIResizeMode", $GUI_DOCKLEFT)
#region ### START Koda GUI section ### Form=c:\users\kristian\desktop\test.kxf
$Test = GUICreate("KnarCraft Client", 945, 1003, 957, 0)
GUISetFont(10, 400, 0, "MT Extra")
$Button1 = GUICtrlCreateButton("Exit", 848, 950, 75, 30)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetTip(-1, "Exits the program")
$Button2 = GUICtrlCreateButton("Start Server", 24, 950, 139, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlSetTip(-1, "Starts the KnarCraft server")
$ToolBar1 = _GUICtrlToolbar_Create($Test, 0)
$Checkbox1 = GUICtrlCreateCheckbox("Hide Console", 32, 928, 113, 17)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Checkbox2 = GUICtrlCreateCheckbox("Old Version", 32, 904, 105, 17)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("D:\Bilder\Gameplay\b7223189a2371e69fabe26c661fae55d.jpeg", 0, 0, 937, 881)
$filemenu = GUICtrlCreateMenu("File")
$fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
$helpmenu = GUICtrlCreateMenu("?")
$aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
$tipsitem = GUICtrlCreateMenuItem("Tips", $helpmenu)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(64, "KnarCraft", "KnarCraft client will now close")
            Exit
        Case $Button2
            Hub_func()
    EndSwitch
WEnd
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
            If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)
        Case $msg = $aboutitem
            MsgBox(0, "About", "GUI Menu Test")
        Case $msg = $tipsitem
            MsgBox(0, "Tips", "You can do lots with this client.")
    EndSelect
WEnd
4

1 回答 1

1

我没有测试你的代码,但从它的外观来看,你的脚本卡在第一个while循环中。AutoIt 脚本必须只有一个事件循环。您应该考虑将第二个循环的条件放入第一个循环,如下所示:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(64, "KnarCraft", "KnarCraft client will now close")
            Exit
        Case $Button2
            Hub_func()
        Case $fileitem
            $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
            If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)
        Case $aboutitem
            MsgBox(0, "About", "GUI Menu Test")
        Case $tipsitem
            MsgBox(0, "Tips", "You can do lots with this client.")
    EndSwitch
WEnd
于 2013-07-19T05:00:00.443 回答