Home > Spotlights, Technical > Guest Article: How to Use AutoIt

Guest Article: How to Use AutoIt

February 12th, 2010 Leave a comment Go to comments

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

Categories: Spotlights, Technical Tags:
  1. February 13th, 2010 at 00:38 | #1

    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
    February 13th, 2010 at 01:21 | #2

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

  3. Remxi
    February 13th, 2010 at 07:15 | #3

    Great tutorial. This is exactly how I use it.

  4. StreakSRM
    February 13th, 2010 at 18:20 | #4

    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.

  5. error1
    February 13th, 2010 at 19:53 | #5

    @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.

  6. Sh33p
    February 14th, 2010 at 00:53 | #6

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

  7. Sh33p
    February 14th, 2010 at 00:57 | #7

    But it’s a good guide anyway, and that patch is EXACTLY what I’ve need looking for.

  8. Sh33p
    February 14th, 2010 at 00:59 | #8

    Er, been.

  9. PimpWilly
    February 17th, 2010 at 19:59 | #9

    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

  10. February 17th, 2010 at 23:43 | #10

    @PimpWilly
    you may be right about that sendkeydowndelay thing. But I like to do my dashes and dragon punches as
    Sleep(20)
    Send (“{right}”)
    Sleep(20)
    Send (“{right}”)
    so that’s why I keep it this way. It’s not 100% consistent but it’s still very consistent.
    this link
    http://forum.arcadecontrols.com/index.php?topic=96377.0
    from the article says it has 64 bit support but I have no way of checking

  11. PimpWilly
    February 18th, 2010 at 09:50 | #11

    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?

  12. February 18th, 2010 at 16:58 | #12

    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.

  13. PimpWilly
    February 18th, 2010 at 17:44 | #13

    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

  14. February 18th, 2010 at 19:24 | #14

    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

  15. crayzieap
    December 5th, 2010 at 03:27 | #15

    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.

  16. Dammit
    December 5th, 2010 at 16:12 | #16

    @crayzieap
    Hey, did you know about AutoMacro?
    http://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

  17. Rufus
    December 5th, 2010 at 22:09 | #17

    @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

  18. WAZAAAAA
    June 9th, 2014 at 11:50 | #18

    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.

  19. June 9th, 2014 at 13:20 | #19

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

  1. February 20th, 2010 at 01:31 | #1
  2. March 23rd, 2010 at 23:16 | #2
  3. July 23rd, 2010 at 11:51 | #3
You must be logged in to post a comment.