Guest Article: How to Use AutoIt

As several people have inquired about tool-assistance in recent weeks, error1 was kind enough to provide a detailed introductory overview on AutoIt. This scripting program is designed to automate complex input tasks, which is a convenient way to execute prohibitively difficult command sequences in PC platform games such as SF4.

 
When Street Fighter 4 came out for the computer, I was practicing AutoHotkey. It worked fine, but had some consistency issues. On gilley‘s advice, I started using AutoIt which seems to be much more consistent. People have asked me how to script in Street Fighter 4 and it being the purpose of this article, I will lay it out for you in some easy-to-follow steps.

But first, a common-sense warning: Please don’t use any of these scripts while playing online matches. It’s just plain cheating and gives all of us TAS’ers a bad name.

1) Install the computer version of SF4. This method can’t help you with PS3 or 360 versions.

2) Download and install AutoIt.

3) Now let me show you a very simple script.

HotKeySet ("1", "lpfb")
HotKeySet ("0", "reload")
While 1
Sleep(100)
WEnd

Func lpfb()
opt ( "SendKeyDelay" ,0)
opt ( "SendKeyDownDelay" ,16.6)
Sleep(100)
Send ("{down down}")
Sleep(20)
Send ("{right down}")
Sleep(20)
Send ("{down up}")
Send ("{a down}")
Sleep(20)
Send ("{a up}")
Send ("{right up}")
EndFunc

Func Reload()
$AutoIt3Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
$ToRun1 = '"' & $AutoIt3Path & '\AutoIt3.exe "' & ' "' & @ScriptFullPath & '"'
Run($ToRun1)
Exit 0
EndFunc

“Send” makes you press a key. Putting “down” after it makes you hold it down. Putting “up” after the key causes you to release it.

“Sleep(20)” makes the computer wait 20 milliseconds before moving on to the next command. One frame is equal to 16.6ms, so rounding off to 20ms can cause some disyncs in your combo. However, desyncs will happen regardless because you never know what part in a frame you’re starting on.

Copy the above code into Notepad and save it as “dan.au3” or something similar.

My first player controls are the arrow keys for directions, A-S-D for punch buttons, and Z-X-C for kicks. If yours are different, you’ll need to change the script to match your keys.

Now run it, go into Training Mode, choose Dan, and press the “1” button. So long as you’re on the left side of the screen, he should do LP Gadoken whenever you press the “1” key.

4) Now let’s try a combo. Change your Gadoken script to this.

Func lpfb()
opt ( "SendKeyDelay" ,0)
opt ( "SendKeyDownDelay" ,16.6)
Sleep(100)
Send ("{down down}")
Sleep(20)
Send ("{x down}")
Sleep(20)
Send ("{x up}")
Sleep(20)
Send ("{right down}")
Sleep(20)
Send ("{down up}")
Send ("{a down}")
Sleep(20)
Send ("{a up}")
Send ("{right up}")
EndFunc

Save the script and press the “0” key to reload the script. Now whenever you press the “1” button, Dan should do a crouching MK and cancel it into LP Gadoken. COMBO!!!

5) What? Two-hit combos not good enough for you? Why in my day we didn’t have those fancy links. Alright, let’s try to link off that Gadoken.

Put your Training Mode Dummy in the corner and set him to “Crouch.” Add this to the end of your script before “EndFunc” then press the “0” key.

Send ("{down down}")
Sleep(810)
Send ("{z down}")
Sleep(20)
Send ("{z up}")
Sleep(20)
Send ("{right}")
Sleep(20)
Send ("{right}")
Sleep(20)
Send ("{d down}")
Sleep(20)
Send ("{d up}")
Send ("{down up}")

Pressing the “1” key against a couching, cornered opponent should cause Dan to execute crouching MK and cancel it into LP Gadoken, then link into crouching LK and cancel that into HP Koryuken. MASSIVE FOUR HIT COMBO!!1!

6) OK but maybe you can do four-hit combos manually. What good are these scripts?

The answer: complex setups. I found this custom patch to get the second controller on the keyboard. It’s what I use and it works great.

My buttons for the second player are “Num 2-4-8-6” for directional buttons, Y-U-I for punch buttons, and H-J-K for kick buttons.

If you want to try a complex setup, use the following script. Fill up all the bars, then put Ken in the left corner and put Ryu all the way to the right. It may take a few tries but you should get something that looks like this.

Func glitch()
opt ( "SendKeyDelay" ,0)
opt ( "SendKeyDownDelay" ,16.6)

Send ("{numpad6 down}")
Send ("{numpad6 down}")
Send ("{numpad6 down}")
Send ("{numpad6 down}")
Send ("{numpad6 down}")
Send ("{numpad8 down}")
Send ("{down down}")
Send ("{right down}")
Send ("{down up}")
Send ("{a}")
Send ("{right up}")
Sleep (150)
Send ("{g down}")
Send ("{right}")
Sleep (16.6)
Send ("{right}")
Sleep (16.6)
Send ("{right}")
Sleep (16.6)
Send ("{right}")
Sleep (16.6)
Send ("{right}")
Sleep (16.6)
Send ("{right}")
Sleep (16.6)
Send ("{g up}")
Sleep (190)
Send ("{up down}")
Send ("{right down}")
Sleep (80)
Send ("{up up}")
Send ("{right up}")
Send ("{down down}")
Send ("{left down}")
Send ("{down up}")
Send ("{c}")
Send ("{left up}")

Sleep (1300)
Send ("{up down}")
Send ("{right down}")
Sleep (100)
Send ("{up up}")
Send ("{right up}")
Send ("{down down}")
Send ("{left down}")
Send ("{down up}")
Send ("{v}")
Send ("{left up}")
Sleep (300)
Send ("{numpad6 up}")
Send ("{numpad8 up}")

Sleep (300)

 
Send ("{down down}")
Send ("{right down}")
Send ("{down up}")
Send ("{right up}")
Send ("{down down}")
Send ("{right down}")
Send ("{down up}")
Send ("{h}")
Send ("{f}")
Send ("{right up}")
Sleep (1970)

 
Send ("{numpad2 down}")
Send ("{numpad4 down}")
Send ("{numpad2 up}")
Send ("{numpad4 up}")
Send ("{numpad2 down}")
Send ("{numpad4 down}")
Send ("{numpad2 up}")
Send ("{y down}")

Send ("{numpad4 up}")
Send ("{y up}")

 
EndFunc

19 thoughts on “Guest Article: How to Use AutoIt

  1. Maj Post author

    Many thanks to error1 for writing this article on such short notice. I don’t know the first thing about AutoIt or scripting for modern games such as SF4, so i couldn’t have done it.

    This is a much more viable alternative than trying to track down a Japanese PS1 programmable controller at this point. I’m totally looking forward to seeing what you guys come up with using these scripting tools.

  2. Bob Sagat

    Awesome. There were some things I wanted to try out so this is some nice help. Thanks Maj and error1!

  3. StreakSRM

    I tried this program out while making my Honda video. I made a script to do low jab, EX hundred hands, low jab, EX hundred hands. I could run the same script over and over and get different results each time.
    1st run, low jab, ex hands, low jab gets blocked
    2nd run, low jab, regular hands
    3rd run, low jab, ex hands, low jab hits, ex hands

    I couldn’t figure out how to get any consistency out of it.

  4. error1

    @StreakSRM
    that’s a tough one because of the rapid button presses and the one frame link to low jab, I would recommend using a button for all three punches, that way you shouldn’t ever get regular hands. And then it’s just the one frame link witch will always give you some problems but if you get it within 10ms it should work most of the time.

  5. Sh33p

    I’d really recommend GlovePie over AutoIt, it serves the exact same function but the scripting commands are much easier in my opinion.

  6. PimpWilly

    Might want to try removing the sendkeydowndelay of 16.6 if you’re running into some oddities, I just set it to 0 for my scripts.

    Also, if anybody can figure out how to get 2P keys configured on a 64 bit os that’d be awesome, so far I’ve been unable to do that, theres only a 32 bit os solution

  7. PimpWilly

    Yeah, I actually tried that same thing. I could tell it was doing something, because it was messing up my controls, but it wasn’t working like it was supposed to because I wasn’t able to get it to recognize both players controls. Thanks for the link though, I think thats the best shot I have at the moment of getting it to work.

    With the send key down delay, I believe it just delays the key send for 16.6 (aka 1 frame), so it wouldn’t stop anything from working but it would make the timings a bit wonky. I also like to use the sleep(16.6) like you did in the last script you posted, and always keep my sleeps multiples of 16.6 so that I can be sure its sleeping the right amount of frames. I don’t tend to have unpredictable results using this method, because a frame is a frame; even if the command is sent “late” during the frame, it will also be sent “late” during the subsequent frame, keeping things in order. Of course that also depends on if your processor can keep up, if the processor is overloaded running SFIV or whatever else, it might lag and the commands aren’t going to come out directly on time.

    I’m also intrigued you can get a dash sending “right” twice, without having to go back to neutral. I always did mine as

    Send (“{right down}”)
    Sleep(16.6)
    Send (“{right up}”)
    Sleep(16.6)
    Send (“{right down}”)
    Sleep(16.6)
    Send (“{right up}”)

    how does auto-it handle not sending the “up” or “down” command?

  8. error1

    the SendKeyDownDelay just holds a key down that much time when ever it is pressed. so
    in other words

    opt ( “SendKeyDownDelay” ,16.6)
    Send (“{right}”)

    should be the same as

    Send (“{right down}”)
    Sleep(16.6)
    Send (“{right up}”)

    I don’t think it does anything if you manually press the key up and down

    Sounds like that patch is working but you have a problem with your button config. You need to make sure the first player is on keybord only in the option menu and you need to know the start button ( the hard part ) for the joystick on the keyboard.

  9. PimpWilly

    Ah, nice yeah I see how it works now, that’s interesting, makes scripting a little easier (for non charge characters) but you give up a bit of flexibility. At least you dont forget an up at the end and end the combo with your character constantly walking in a direction like I constantly do

  10. error1

    In long scripts if I find myself ending it early a lot and leaving buttons pressed I’ll do this

    Func Reload()

    Send (“{numpad6 up}”)
    Send (“{down up}”)
    Send (“{left up}”)
    Send (“{d up}”)
    Send (“{f up}”)
    Send (“{right up}”)
    Send (“{DoWn up}”)
    Send (“{a up}”)
    Send (“{x up}”)

    $AutoIt3Path = RegRead(“HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt”, “InstallDir”);installDir for production
    $ToRun1 = ‘”‘ & $AutoIt3Path & ‘\AutoIt3.exe “‘ & ‘ “‘ & @ScriptFullPath & ‘”‘
    Run($ToRun1)
    Exit 0

    EndFunc

  11. crayzieap

    Hey guys,

    I was wondering if anyone can help me put in the basic script to do hundred handslap type of moves. I am only getting single melee inputs and its not fast enough to initiate the rapid input type of special.

  12. Dammit

    @crayzieap
    Hey, did you know about AutoMacro?
    https://sonichurricane.com/?p=3828

    It didn’t exist when this article was first written. It’s a way to send AutoIt scripts in the same format as MacroLua. They have the same homepage.

    For example, to press jab and then mash fierce 20 times, you write this in the mis file:

    1.(3..)20

  13. Rufus

    @crayzieap
    If you really don’t want to use AutoMacro, you could also do something like:
    for $i=1 to 5
    send({e down})
    sleep({16.6})
    send({e up})
    sleep(16.6)
    next

  14. WAZAAAAA

    AutoIt better than AutoHotkey because of consistency issues? :sadface:
    There are tons of optimizations that can be done to AutoHotkey, I have gathered them in a SRK thread, macro creators on PC that use AHK may find this useful: http://forums.shoryuken.com/discussion/188456/optimize-your-autohotkey-macro-scripts
    Btw, if you’re going to download AHK just make sure to get it from ahkscript.org, because the adminazi of autohotkey.com went ballshit insane and has put downloads to 5 years old versions of the program on the homepage, lol.

  15. Maj Post author

    Thanks for the info, sir. Hopefully the next person who stumbles onto this page through web search will find it useful!

Leave a Reply