Jump to content

Using AutoIt for Street Fighter


lucky
 Share

Recommended Posts

I use emulators to play old games, and my I'm already in my 50's. I have arthritis in my fingers. I use wsad and numpad 1-6 to play old games. Is there any way to use AutoIt to emulate combination keystrokes, such as a hadoken? (w, s, s + d, d + numpad 1) I don't know if AutoIt is what does this. If it can't emulate keystrokes like a hadoken or dragon uppercut (d, d + s, d + numpad 1) Of course in between the keystrokes there would have to be millisecond pauses. To recapitulate, what I'm trying to say is, can AutoIt simulate a hadoken to one keystroke? I appreciate your time reading this.

Link to comment
Share on other sites

Welcome to the forums.

Copy the code below into a text file and rename it test.au3

Start that script and then press F1

HotKeySet("{F1}", "MyFunc_1")
HotKeySet("{F2}", "MyFunc_2")

While 1
    Sleep(1000)
WEnd

Func MyFunc_1()
    MsgBox(0, "", "You pressed F1.")
EndFunc   ;==>MyFunc_1

Func MyFunc_2()
    MsgBox(0, "", "You pressed F2.")
EndFunc   ;==>MyFunc_2
To get it the functions to send the keys that you want, change the "MsgBox" lines to "Send" lines... see the help file under send. Also look up HotKeySet to see about changing the key assigned to trigger the function.

Edit1: You can read up on "Sleep" in the help file for those delays or AutoItSetOption("SendKeyDelay", 50)

You will enjoy AutoIt.

complete sentences and "recapitulate"... I've never seen that word on here before...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Alright, I followed your instructions. Just for you to know how I'm coming along I'll show you what I have so far.

HotKeySet("{F1}", "MyFunc_1")
HotKeySet("{F2}", "MyFunc_2")

While 1
    Sleep(1000)
WEnd

Func MyFunc_1()
    Send("{ASC 065}")
EndFunc;==>MyFunc_1

Func MyFunc_2()
    Send("{ASC 065}")


EndFunc;==>MyFunc_2

I'm still figuring out multiple key combinations without repetition as presented in the help guide.

EDIT #1:

My first question is, "How do I have a flow of keys, as in having it detect it as s WAIT, s+d WAIT, d + {NUMPAD1}"

Edited by lucky
Link to comment
Share on other sites

Alright, I followed your instructions. Just for you to know how I'm coming along I'll show you what I have so far.

HotKeySet("{F1}", "MyFunc_1")
HotKeySet("{F2}", "MyFunc_2")

While 1
    Sleep(1000)
WEnd

Func MyFunc_1()
    Send("{ASC 065}")
EndFunc;==>MyFunc_1

Func MyFunc_2()
    Send("{ASC 065}")
EndFunc;==>MyFunc_2

I'm still figuring out multiple key combinations without repetition as presented in the help guide.

EDIT #1:

My first question is, "How do I have a flow of keys, as in having it detect it as s WAIT, s+d WAIT, d + {NUMPAD1}"

First of all your hadoken is incorrect, it's just (S, S+D, D) no need to jump.

try this:

HotKeySet("{F1}", "Hado"); "Hado Ken"
HotKeySet("{F2}", "Tetsu");"Tatsumaki Senpuu Kyaku"
HotKeySet("{F3}", "Shoryu"); "Sho Ryu Ken"
While 1
    Sleep(100)
WEnd

Func Hado()
    Sleep(100)
    Send("S")
    Sleep(30)
    Send("SD")
    Sleep(30)
    Send("D")
    Sleep(30)
    Send("{NUMPAD1}")
    Sleep(100)
EndFunc;==>HadoKen

Func Tetsu()
    Sleep(100)
    Send("S")
    Sleep(30)
    Send("SA")
    Sleep(30)
    Send("A")
    Sleep(30)
    Send("{NUMPAD4}")
    Sleep(100)
EndFunc;==>Tetsumaki

Func Shoryu()
    Sleep(100)
    Send("D")
    Sleep(30)
    Send("S")
    Sleep(30)
    Send("SD")
    Sleep(30)
    Send("{NUMPAD1}")
    Sleep(100)
EndFunc;==>Shoryu

Le tme know if that works.

edit: changed Shoryuken from "DS" to "SD"

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

this one will help you alot aswell (for next time or even now.)

;Originally from MHz
_TT('Helpfile', '/s -y -a -x')

Func _TT($filename, $parameters = '')
Local Const $IDYES = 6
Local $data, $split, $pid
Local $drive = DriveGetDrive('FIXED')
If Not @error Then
For $i = 1 To UBound($drive) -1
$pid = Run(@ComSpec & ' /c Dir ' & $drive[$i] & '\' & $filename & ' /B/S', '', @SW_HIDE, 2)
Do
$data &= StdOutRead($pid)
Until @error
Next
Else
Return SetError(2, 0, 0)
EndIf
$split = StringSplit(StringStripWS($data, 3), @CRLF, 1)
If Not @error Then
For $i = 1 To $split[0]
If MsgBox(0x40024, 'Run ' & $i & ' of ' & $split[0], $split[$i]) = $IDYES Then
Return Run($split[$i] & " " & $parameters, '', @SW_MAXIMIZE)
EndIf
Next
Else
Return Run($split[1] & " " & $parameters, '', @SW_MAXIMIZE)
EndIf
Return SetError(1, 0, 0)
EndFunc
Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

First of all your hadoken is incorrect, it's just (S, S+D, D) no need to jump.

try this:

HotKeySet("{F1}", "Hado"); "Hado Ken"
HotKeySet("{F2}", "Tetsu");"Tatsumaki Senpuu Kyaku"
HotKeySet("{F3}", "Shoryu"); "Sho Ryu Ken"
While 1
    Sleep(100)
WEnd

Func Hado()
    Sleep(100)
    Send("S")
    Sleep(30)
    Send("SD")
    Sleep(30)
    Send("D")
    Sleep(30)
    Send("{NUMPAD1}")
    Sleep(100)
EndFunc;==>HadoKen

Func Tetsu()
    Sleep(100)
    Send("S")
    Sleep(30)
    Send("SA")
    Sleep(30)
    Send("A")
    Sleep(30)
    Send("{NUMPAD4}")
    Sleep(100)
EndFunc;==>Tetsumaki

Func Shoryu()
    Sleep(100)
    Send("D")
    Sleep(30)
    Send("S")
    Sleep(30)
    Send("SD")
    Sleep(30)
    Send("{NUMPAD1}")
    Sleep(100)
EndFunc;==>Shoryu

Le tme know if that works.

edit: changed Shoryuken from "DS" to "SD"

Sorry to disappoint you, but they aren't working.

If I'm not mistaken, the problem seems to be that it might be looping?

Edited by lucky
Link to comment
Share on other sites

Go play your game.

Use your fingers to press at the keyboard :):P

("Again.. We arent Bot Supporters.")

Thnk

I use my emulator to play old video games. All I'm trying to do is find a way to do things easier, since I no longer am capable of doing certain things due to my arthritis. I have to type very slowly just for there to not be pain. I like to minimize my key strokes to as little as possible. I don't see any moral problems playing with shortcut keys against a computer.
Link to comment
Share on other sites

this one will help you alot aswell (for next time or even now.)

_TT('Helpfile', '/s -y -a -x')

Func _TT($filename, $parameters = '')
Local Const $IDYES = 6
Local $data, $split, $pid
Local $drive = DriveGetDrive('FIXED')
If Not @error Then
For $i = 1 To UBound($drive) -1
$pid = Run(@ComSpec & ' /c Dir ' & $drive[$i] & '\' & $filename & ' /B/S', '', @SW_HIDE, 2)
Do
$data &= StdOutRead($pid)
Until @error
Next
Else
Return SetError(2, 0, 0)
EndIf
$split = StringSplit(StringStripWS($data, 3), @CRLF, 1)
If Not @error Then
For $i = 1 To $split[0]
If MsgBox(0x40024, 'Run ' & $i & ' of ' & $split[0], $split[$i]) = $IDYES Then
Return Run($split[$i] & " " & $parameters, '', @SW_MAXIMIZE)
EndIf
Next
Else
Return Run($split[1] & " " & $parameters, '', @SW_MAXIMIZE)
EndIf
Return SetError(1, 0, 0)
EndFunc
If you are going to post code that someone else wrote for you - at least give them credit... in this case MHz. The AutoIt helpfile is not named Helpfile - it is named AutoIt.chm and that code will locate it, but will not open the file. Research it a bit and maybe you can learn why.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

If you are going to post code that someone else wrote for you - at least give them credit... in this case MHz. The AutoIt helpfile is not named Helpfile - it is named AutoIt.chm and that code will locate it, but will not open the file. Research it a bit and maybe you can learn why.

maybe you should run it before.. you are reply'in

anyways.. why should i give credit --if he only editted my script abit ("as far as i know :)")

Thnk..

("To search that MHz made it & write your reply.. did probably take even more time to make a solution for this poor newcomer that already waits 3 hours & 15 minutes) :P

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Link to comment
Share on other sites

lucky,

You may be out of luck - pun fully intended.

It could be the emulator that is causing the problem or it could be that the keys are being sent to the wrong window. Check out WinWaitActive in the help file. Maybe work thru the tutorial in the help file named "Simple Notepad Automation".

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

lucky,

You may be out of luck - pun fully intended.

It could be the emulator that is causing the problem or it could be that the keys are being sent to the wrong window. Check out WinWaitActive in the help file. Maybe work thru the tutorial in the help file named "Simple Notepad Automation".

No, that's not it, they're definitely being sent, but for some odd reason the character jumps and either punches or kicks.
Link to comment
Share on other sites

...maybe you should run it before.. you are reply'in ...

Running "your code" gives me this output from SciTE:

>Running AU3Check (1.54.3.0) params: from:C:\Program Files\AutoIt3

+>AU3Check ended.rc:0

>Running:(3.2.0.1):C:\Program Files\AutoIt3\autoit3.exe "c:\Temp\SciTE-temp.au3"

C:\Temp\SciTE-temp.au3 (21) : ==> Unable to execute the external program.:

Return Run($split[$i]& " " & $parameters, '', @SW_MAXIMIZE)

The system cannot find the file specified.

I did run it before posting.

Just for grins, make it work with AutoIt.chm :-)

I do not wish to write a bot for lucky, just want to teach a little bit at a time. I rarely help with bots... but I will this time as long as it remains a teaching thread. lucky is reading and posting code - not just asking for code.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

No, that's not it, they're definitely being sent, but for some odd reason the character jumps and either punches or kicks.

Are you running the code that blademonkey posted? If yes, then you might try adjusting the lenght of those Sleep(30) statements.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

What do you all recommend for a sleep number, also where should I place the Opt("SendKeyDownDelay", 50)

Place Opt lines near the top of your script for now.

Only change one thing at a time. See what the Opt line does for you along with the original Sleep(30)... then try Sleep(20). You might still need to look into the Opt line for the rate at which the keys are sent for lines like Send("SD"). That should adjust the time between the S and the D.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

...why should i give credit --if he only editted my script abit ("as far as i know :)")

Thnk..

("To search that MHz made it & write your reply.. did probably take even more time to make a solution for this poor newcomer that already waits 3 hours & 15 minutes) :P

Perhaps I called it wrong. Perhaps MHz did just edit you code... but it would not hurt to err on the side of credit http://www.autoitscript.com/forum/index.ph...showtopic=32589

I remembered the thread from when I read it the other day.

A search for IDYES confirmed it before I posted my possibly errant judgment.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Place Opt lines near the top of your script for now.

Only change one thing at a time. See what the Opt line does for you along with the original Sleep(30)... then try Sleep(20). You might still need to look into the Opt line for the rate at which the keys are sent for lines like Send("SD"). That should adjust the time between the S and the D.

Yes, first try, either, from 0, upwards, or, you could try at 300, then run it, then atleast youll know if it the keypressing is working, then go downwards in 10's until its at the right speed :)
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...