Trying to create a macro, but im bad at coding
Trying to create a macro, but im bad at coding
I'm not a programmer, I just want my pc to hold my d and space bar for ~19s and then hold my s and space bar for ~ 19s, loop it a few times and have a button to pause the script. Pls help i have no idea what im doing.
Re: Trying to create a macro, but im bad at coding
Welcome to this AutoHotkey forum!
Why release the key immediately if you actually want to keep it pressed? You can send the key up after the sleep.
Did you write this script?
Why are you posting an image of your script, instead of actual code?
What happens when you run this script?
Why release the key immediately if you actually want to keep it pressed? You can send the key up after the sleep.
Did you write this script?
Why are you posting an image of your script, instead of actual code?
What happens when you run this script?
Re: Trying to create a macro, but im bad at coding
1) thats true, how would I format it to have all the keypresses as down, then sleep then up? Like this
[Mod edit: [code][/code] tags added. Please use them yourself going forward.]
2) I did write it but I'm just reading the start guide and using commands that I think should work I have no idea how to code a macro
3) Idk, If sending the actual code is easier I'll send that in the future
4) running the script says line 8 is missing it's opening brace
Code: Select all
1: SendInput "{d down}" "{Spacedown]"
sleep 19000
SendInput "{d up}" "{a down}"
sleep 19000
SendInput "{a up}" "{space up}"
2) I did write it but I'm just reading the start guide and using commands that I think should work I have no idea how to code a macro
3) Idk, If sending the actual code is easier I'll send that in the future
4) running the script says line 8 is missing it's opening brace
Re: Trying to create a macro, but im bad at coding
You are on the right track. Below is a revision that you can adjust. You were mixing v1 and v2 code-- not allowed! If you want v2, then use the v2 documentation.
You can add a hotkey that calls the Pause function, keeping in mind that one or more keys may be down at that time.
Code: Select all
#Requires AutoHotkey v2.0
wait := 500
1:: {
Send '{d down}{Space down}'
Sleep wait
Send '{d up}{a down}'
Sleep wait
Send '{a up}{Space up}'
SoundBeep 1500
}
Re: Trying to create a macro, but im bad at coding
ty I'll try this
Re: Trying to create a macro, but im bad at coding
Code: Select all
#Requires AutoHotkey v2.0
wait := 19500
loopCount := 0
isPaused := false
^t:: ; Toggle switch hotkey
{
if (isPaused) {
isPaused := false
MsgBox, Script is now resumed.
} else {
isPaused := true
MsgBox, Script is now paused.
}
return
}
`::
{
if (isPaused)
return
loopCount := 0
While (loopCount < 10)
{
Send, {d down}{Space down}
Sleep, wait
Send, {d up}{s down}
Sleep, wait
Send, {s up}{Space up}
SoundBeep, 1500
loopCount++
}
return
}
there's something wrong when I try to pause it like this, but I'm not sure how to use suspend
Re: Trying to create a macro, but im bad at coding
My first question is whether the script that I posted works. That will tell us whether we have a working starting point.
Re: Trying to create a macro, but im bad at coding
It works yes
Re: Trying to create a macro, but im bad at coding
Your first step is deciding which version of AutoHotkey you would like to use. Your second step is writing the script in that version. Would tackle that first. The debugging can then be done. The AHK documentation contains examples of every function, directive, object, and control flow statement, so you can model your code based on the syntax in the examples.