未知问题,数字未输入计数器

Unknown issue, Numbers not inputting for a counter

我正在为不和谐计数器制作 AHK 脚本。无用的东西,但我正在尝试学习如何使用 AHK 和使用 GUI 系统。这是我第一次制作 GUI,我有一个工作计数器代码。我想通过制作一个图形用户界面使其对用户友好,以便您可以更改值。

我试过在变量周围添加 % 和删除 %。在这一点上我真的很困惑。

这是我正在使用的有效非 GUI 代码

F11::Goto,lol
ESC::ExitApp,

lol:
; example add 1
VAR1 := (1)
VAR2 := (11492)

Loop,300
{
VAR2 := (VAR2+VAR1)
Send, %VAR2%
Send, {Enter}
Sleep, 6500
}
return

这是我在带有变量的 GUI 系统中使用的代码。

; Simple counter script. This is for Discord counting
Gui, Show , w210 h200, Counter

; GUI stuff
Gui, Add, Text, x20 y10 w130 Left,Input a number for delay:
Gui, Add, Text, x20 y50 w130 Left,Input a starting number:
Gui, Add, Text, x20 y90 w130 Left,Input a number to add by:
Gui, Add, Text, x20 y120 w130 Left,Input a number for the number of loops:
Gui, Add, Text, x0 y160 w200 Center,Press F11 to start the script
Gui, Add, Text, x0 y180 w200 Center,Made by Pyro#5249
Gui, Add, Edit, w50 h19 x150 y10 vDelay Left, 
Gui, Add, Edit, w50 h19 x150 y50 vSTART Left, 
Gui, Add, Edit, w50 h19 x150 y90 vADD Left,
Gui, Add, Edit, w50 h19 x150 y120 vLOOP Left,
F11::goto,lol
return

lol:
{
VAR1 := (%ADD%)
VAR2 := (%START%)

Loop,%LOOP%
{
VAR2 := (VAR2+VAR1)
Send, %VAR2%
Send, {Enter}
Sleep, %DELAY%
}
return
}

GuiClose: 
ExitApp

ESC::ExitApp,

我希望它在 F11 上启动并开始列出 couning。如

1
2
3
4
5
6
ect...

但到目前为止我什么也没得到。没有结果。

你有一个好的开始!以下是一些应该有所帮助的事情:

  • 如果要从 GUI 获取值,则需要使用 Gui , Submit。如果您想让 Gui 保持运行状态,请使用 NoHide 选项 (Gui , Submit , NoHide)。
  • 当您使用 := 分配值时,不使用百分比。因此,VAR := ADD 会将变量 "ADD" 的值赋给变量 "VAR"。您可以仅使用 = 来分配值,而无需像现有的那样使用百分号 (VAR = %ADD%),但这仅在旧脚本中受支持,不建议在新脚本中使用。
  • 有些东西需要用大括号 {} 括起来,就像您对循环所做的那样,但有些东西不需要,例如 "lol" 标签。
  • 您可以在一个发送命令中发送多个内容,而不是将其拆分为两个单独的发送命令。

AutoHotkey help documentation 非常好,可以很好地理解正确的语法。这是你的脚本的一个工作示例,它显示了一个消息框计数器,因为我不知道你想在哪里输入值(我把那部分注释掉了)。

; Simple counter script. This is for Discord counting
Gui, Show , w210 h200, Counter

; GUI stuff
Gui, Add, Text, x20 y10 w130 Left,Input a number for delay (ms):
Gui, Add, Text, x20 y50 w130 Left,Input a starting number:
Gui, Add, Text, x20 y90 w130 Left,Input a number to add by:
Gui, Add, Text, x20 y120 w130 Left,Input a number for the amount of loops:
Gui, Add, Text, x0 y160 w200 Center,Press F11 to start the script
Gui, Add, Text, x0 y180 w200 Center,Made by Pyro#5249
Gui, Add, Edit, w50 h19 x150 y10 vDelay Left, 
Gui, Add, Edit, w50 h19 x150 y50 vSTART Left, 
Gui, Add, Edit, w50 h19 x150 y90 vADD Left,
Gui, Add, Edit, w50 h19 x150 y120 vLOOP Left,
F11::goto,lol
return

lol:
Gui , Submit , NoHide
VAR1 := ADD
VAR2 := START

Loop , %LOOP%
{
    VAR2 += VAR1
    MsgBox ,, Counter , Counter value = %VAR2% , % DELAY / 2000
    Sleep , % DELAY / 2 ; halved delay since MsgBox is also half the delay
;    Send, %VAR2%{Enter}
;    Sleep, %DELAY%
}
return

GuiClose: 
ExitApp