我做了一个组合:
$Combo1 = GUICtrlCreateCombo("Java Memory", 24, 872, 145, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M")
然后我添加了一些内容来阅读它:
$chosen = GUICtrlRead($Combo1)
然后我制作了一个跑步命令,并选择了$:
Run ("java -jar spigot-1.6.2-R0.1.jar " & $chosen, "E:\Spill\Alle spill\Minecraft\KnarCraft 2013")
当我没有在下拉列表中选择一个选项时,它就会启动。当我这样做时,它会立即消失,但它会显示所有有效参数,因此它的读取方式有问题。我认为它与之有关 - 但我不知道应该怎么做。我尝试使用 - 然后使用变量,但随后将其读作 - $选择而不是" - " +"选择$中的选择"。
答案 0 :(得分:1)
例如:
$Combo1 = GUICtrlCreateCombo("Java Memory", 10, 10, 142, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "-Xmx100M|-Xmx200M|-Xmx400M|-Xmx800M|-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M")
然后查看是否有任何较小的数字有效,以及较大的数字是否会破坏程序。
我的测试程序:
AutoIt程序,MyFoo.au3:
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $msg
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
$Combo1 = GUICtrlCreateCombo("Java Memory", 10, 10, 142, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "-Xmx100M|-Xmx200M|-Xmx400M|-Xmx800M|-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M")
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $Combo1 Then
$chosen = GUICtrlRead($Combo1)
$runString1 = "java " & $chosen & " -jar MyFoo.jar"
$runString2 = "java -jar MyFoo.jar " & $chosen
ConsoleWrite($runString1 & @CRLF)
Run($runString1)
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc
Java测试程序,MyAutoItFoo.java。当然这首先是jar:
import javax.swing.JOptionPane;
public class MyAutoItFoo {
public static void main(String[] args) {
long heapSize = Runtime.getRuntime().totalMemory();
long heapMaxSize = Runtime.getRuntime().maxMemory();
String heapString = String.format("Heap Size = %H; Max Heap = %H",
heapSize, heapMaxSize);
System.out.println(heapString);
JOptionPane.showMessageDialog(null, heapString);
}
}