1. The program that I am trying to send the inputs to runs at 60 fps (a racing game), so depending on when I start the program, the output will be different in the game. I assume this is because of lag and also because my input system uses the sleep command, which runs in milliseconds (100 fps). This means that depending on when I start the script the time that the inputs are executed will change.
2. There is a couple frames of no input when the code is decoding the script to figure out what next to input, and I'm sure this could be fixed with some optimizations in the code.
Here is the code:
Code: Select all
#SingleInstance, Force
Setbatchlines -1
linenum := 1
FileReadLine, text, Inputs.txt, linenum
outputs := StrSplit(text, ":")
Keys := outputs[1]
extime := outputs[2]
Loop
{
if (GetKeyState("P") = 1)
break
}
Loop
{
Sleep extime
SendKeys := StrSplit(Keys, ",")
K1 := SendKeys[1]
K2 := SendKeys[2]
K3 := SendKeys[3]
K4 := SendKeys[4]
Send,{W Up}
Send,{A Up}
Send,{S Up}
Send,{D Up}
Send,{%K1% Down}
Send,{%K2% Down}
Send,{%K3% Down}
Send,{%K4% Down}
linenum += 1
FileReadLine, text, Inputs.txt, linenum
outputs := StrSplit(text, ":")
Keys := outputs[1]
extime := outputs[2]
if (extime = 0000)
break
sleep, 1
}
ESC::ExitApp
W,A:1000
W:120
W,D:4600
W:200
S,D:1600
W:1600
W,D:2700
S,D:2500
W:1900
As you can see above, the inputs that the script is supposed to perform is written before the colon and each letter of input is separated by a comma. After the colon, there is the amount of time that the script should wait before executing the given input (This is all in the script at the top).
Does anyone have any suggestions on how to fix my problems?
[Mod edit: Replaced the bold tags with [code][/code] tags. Please use them yourself when posting code. Also removed extra blank lines in post.]
[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code and to the "Gaming" section within that.]