从输入表单发送变量会发送一个数字而不是变量值

时间:2013-05-28 02:37:18

标签: variables autoit

不是像它应该那样显示文本,而是每次只发送一个数字。

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 487, 551, 299, 250)
GUISetBkColor(0x800000)
$what1 = GUICtrlCreateInput("What to run:", 64, 120, 393, 21)
$run1 = GUICtrlCreateButton("Run this!", 64, 152, 129, 25)
$what2 = GUICtrlCreateInput("What to run:", 64, 192, 393, 21)
$run2 = GUICtrlCreateButton("Run this!", 64, 224, 129, 25)
$what3 = GUICtrlCreateInput("What to run:", 64, 264, 393, 21)
$run3 = GUICtrlCreateButton("Run this!", 64, 296, 129, 25)
$what4 = GUICtrlCreateInput("What to run:", 64, 336, 393, 21)
$run4 = GUICtrlCreateButton("Run this!", 64, 368, 129, 25)
$Label1 = GUICtrlCreateLabel("NativePrison", 16, 0, 339, 72)
GUICtrlSetFont(-1, 36, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0x008000)
$Label2 = GUICtrlCreateLabel("AUTO-RUNNER", 184, 64, 271, 49)
GUICtrlSetFont(-1, 24, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0x000080)
$Label3 = GUICtrlCreateLabel("1", 24, 128, 20, 37)
GUICtrlSetFont(-1, 18, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xC0C0C0)
$Label4 = GUICtrlCreateLabel("2", 24, 200, 20, 37)
GUICtrlSetFont(-1, 18, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xC0C0C0)
$Label5 = GUICtrlCreateLabel("3", 24, 272, 20, 37)
GUICtrlSetFont(-1, 18, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xC0C0C0)
$Label6 = GUICtrlCreateLabel("4", 24, 344, 20, 37)
GUICtrlSetFont(-1, 18, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xC0C0C0)
$runall = GUICtrlCreateButton("RUN ALL!", 8, 400, 473, 145)
GUICtrlSetFont(-1, 48, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $run1
           WinActivate("Minecraft")
           Send("{ESC}")
           Send("t")
           Send($what1)
           Send("{Enter}")
        Case $run2
           WinActivate("Minecraft")
           Send("{ESC}")
           Send("t")
           Send($what1)
           Send("{Enter}")
        Case $run3
           WinActivate("Minecraft")
           Send("{ESC}")
           Send("t")
           Send($what1)
           Send("{Enter}")
        Case $run4
           WinActivate("Minecraft")
           Send("{ESC}")
           Send("t")
           Send($what1)
           Send("{Enter}")
        Case $runall
           WinActivate("Minecraft")
           Send("{ESC}")
           Send("t")
           Send($what1)
           Send("{Enter}")
           Send("t")
           Send($what2)
           Send("{Enter}")
           Send("t")
           Send($what3)
           Send("{Enter}")
           Send("t")
           Send($what4)
           Send("{Enter}")
    EndSwitch
WEnd

2 个答案:

答案 0 :(得分:1)

$what1ControlID,因此它在运行Send($what1)时返回数字3。

在您已经打开Minecraft之后不确定目的是什么,但是Send($what1)应该在{{1}中运行应用程序路径(例如“C:\ application \ app.exe”)输入框?

如果这是您正在寻找的,那么您应该阅读输入并将其分配给变量,而不是使用$what1命令,而是使用Send()命令。

以下是您应该如何编写案例Run()的一个示例:

$run1

答案 1 :(得分:0)

您没有从GUI中读取输入。

您所需要的只是:

GUICtrlRead($what1)

我今天做了同样的事情 - 暂时没有创建GUI输入 - 哎呀!