AutoIT Server菜单命令提示

时间:2013-07-18 12:07:10

标签: batch-file autoit minecraft

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

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

1 个答案:

答案 0 :(得分: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
相关问题