Reputation: 17
I am making a AHK script for a discord counter. Useless stuff but im trying to learn how to AHK and work with a GUI system. This is my first time making a GUI and i have a working counter code. I want to make it user friendly by making a gui so you can change the values.
I have tried adding % and removing % around the variables. At this point I'm really confused.
This is the working NON GUI code I'm using
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
And this is the code im using with my GUI system with variables.
; 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,
I want it to start on F11 and start listing off the couning. Such as
1
2
3
4
5
6
ect...
But as of now im not getting anything. No results.
Upvotes: 0
Views: 51
Reputation:
You have a good start! Here are a few things that should help:
Gui , Submit
. If you want the Gui to stay up, use the NoHide
option (Gui , Submit , NoHide
).:=
, percents aren't used. So, VAR := ADD
would assign the value of the variable "ADD" to the variable "VAR". You can assign values with just =
and you wouldn't need to use percent-signs as you have it (VAR = %ADD%
), but this is only supported for legacy and isn't recommended for new scripts.{}
as you have done with the loop, but some things do not, such as the "lol" label.The AutoHotkey help documentation is excellent and will give a good understanding of proper syntax. Here is a working example of your script with it showing a message box counter since I don't know where you want to type the values (I commented that portion out).
; 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
Upvotes: 1