我正在为不和谐柜台制作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 ammount 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...
但是到目前为止,我什么也没得到。没有结果。
答案 0 :(得分:1)
您有一个好的开始!这里有几件事应该有所帮助:
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