autohotkey - 未知问题,未输入计数器的数字
问题描述
我正在为不和谐计数器制作 AHK 脚本。没用的东西,但我正在尝试学习如何 AHK 和使用 GUI 系统。这是我第一次制作 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 开始并开始列出。如
1
2
3
4
5
6
ect...
但截至目前,我什么也没得到。没结果。
解决方案
你有一个好的开始!以下是一些应该有所帮助的事情:
- 如果要从 GUI 获取值,则需要使用
Gui , Submit
. 如果您希望 Gui 保持不变,请使用NoHide
选项 (Gui , Submit , NoHide
)。 - 当您使用 分配值时
:=
,不使用百分比。因此,VAR := ADD
将变量“ADD”的值分配给变量“VAR”。您可以使用 just 分配值,=
并且您不需要使用百分号 (VAR = %ADD%
),但这仅支持旧版脚本,不建议用于新脚本。 - 有些东西需要用大括号括起来,
{}
就像你对循环所做的那样,但有些东西不需要,比如“lol”标签。 - 您可以在一个发送命令中发送多个内容,而不是将其拆分为两个单独的发送命令。
AutoHotkey 帮助文档非常好,可以很好地理解正确的语法。这是您的脚本的一个工作示例,它显示了一个消息框计数器,因为我不知道您要在哪里输入值(我已将那部分注释掉)。
; 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
推荐阅读
- javascript - 为什么javascript在标准化颜色字符串的方式上不一致?
- c# - 将光标锁定到轨迹球视图
- python - 使用 python tkinter 进行网络摄像头录制
- java - 如何为 LinearLayout 动态设置权重?
- php - XML 结构破坏提要产生错误文档为空
- c#-4.0 - 使用 BouncyCastle 库在 C# 中进行 HTTPS 调用
- stackdriver - 通过 Monitoring v3 API 创建 Stackdriver 提醒政策
- javascript - JavaScript - 按下按钮后保存所选项目
- excel - 用于检查一列中的值组合以匹配另一列中的组合的公式
- python - 排列和合并数据框