0
votes

Im trying to make an ahk script to try and simplify a one time use script. Pretty much im running over 1000 commands in a game one after one another .Currently I have something like this. I have all the commands in a single text file just not with any ahk coding.

.waypointadd 1 100234 40 -469
.waypointadd 2 99549 34 5
.waypointadd 3 100615 37 -160
.waypointadd 4 100817 27 -457
.waypointadd 5 100503.5 10.5 -647.5
.waypointadd 6 100494.5 10.5 -625.5

This goes on for a while. Im new to using expressions and such and am pretty much trying to make it to press enter, type the command, then press enter, then go to the next one. I obviously cant do this manually. I have tried using some basic replace expressions and stuff but not really sure how to do this.

In the end i would want it to look like this

send {enter}
send (command 1)
send {enter}
send {enter}
send (command 2)
send {enter}
2

2 Answers

0
votes

you could bind it to a key like....

1::
loop, 1 {
  send {enter}
  send (command 1)
  send {enter}
  send {enter}
  send (command 2)
  send {enter}
}

or make a function when you a press a key. lmk if this helps or not

doSomething() {
  send {enter}
  send (command 1)
  send {enter}
  send {enter}
  send (command 2)
  send {enter}
}

1::
doSomething()
0
votes

You could store all the commands in your clipboard (CTRL+C them) and then loop through all of them:

Loop, Parse, Commands, `n, `r ;split by linefeed, ignore carriage return
{
    SendInput, % A_LoopField "{Enter 2}"
    Sleep, 1000 ;however long you need
}

Loads of ways to get the commands into your script, I just went with loading them from your clipboard, should be pretty easy convenient to just copy the block of commands you want and then starting the script.
Then there's a parsing loop.
And then SendInput is used to send the current command follow by two presses of Enter.
Alternatively, if your game supports pasting from clipboard, it would be nice to just load your clipboard with whatever you want to send, and then sending a CTRL+V.

If the code with SendInput is going too fast, you can try switching over to normal Send and maybe even using SetKeyDelay to add even more delay between the keypresses.