Jump to content
LaunchBox Community Forums

AutoHotKey script for MAME


Recommended Posts

#NoEnv

; =================================================================================
; FOR MAME TO ACCEPT AHK SCRIPTS keyboardprovider IN mame.ini MUST BE SET TO dinput!
; =================================================================================

; Fast Forward
4Joy15::
If GetKeyState("4Joy15")
{
   SetKeyDelay, -1, 110
   MmC:=!MmC
   if MmC = 1
      Send {Insert down}
   else
      Send {Insert up}
   return
}
Return

; Pause
4Joy20::
If GetKeyState("4Joy20")
{
   SetKeyDelay, -1, 110
   Send {p}
}
Return

; Exit
4Joy17::
If GetKeyState("4Joy17")
{
   SetKeyDelay, -1, 110
   Send {escape}
}
Return

; Load State
4Joy18::
If GetKeyState("4Joy18")
{
   SetKeyDelay, -1, 110
   Send {F7 up}{Shift up}
   Sleep 100
   Send {F7}
   Sleep 100
   Send {s}
}
Return

; Save State
4Joy19::
If GetKeyState("4Joy19")
{
   SetKeyDelay, -1, 110
   Send +{F7}
   Sleep 50
   Send {s}
}
Return

 

This is a series of small scripts mapping various MAME functions (Load State, Save State, Pause, Exit, Fast Forward) to gamepad buttons on my 4th controller. Modify the scripts to map them to your own controllers or add new ones - you may also need to modify some timings in the Sleep, SetKeyDelay commands if a script doesn't work for you.

NOTE1: If you don't want to modify your mame.ini, open Launchbox, go to the Default Command-Line parameters for MAME and add: -keyboardprovider dinput

This is needed so MAME can accept input from AutoHotKey.

NOTE2: The Save States script, saves a state with the name "s" automatically (and the Load State script loads it back). You can change the "s" to any other number/letter on both scripts or you can remove the Sleep 50, Sleep 100 & Send {s} lines if you want to save states manually.

 

Edited by Crush
Link to comment
Share on other sites

User could also just set these controls to two button combos sent from the 1st player controller on my arcade machine coin and start together is tab  coin and one of the buttons on my front panel exit  coin and 5 is save coin and 6 is load so on a controller you would just replace coin with select and do the same thing. To map combos in MAME just press both buttons simultaneously while it is waiting for you to enter input. This way you can still use XInput you don't have to mess with AHK at all and control things all from the 1st player.

Edited by DOS76
Link to comment
Share on other sites

  • 6 months later...

Encountered this post and wanted to ask, has anyone gotten the save state/load state script to work for MAME?

Been trying various things and can't get anything to stick. Farthest is leep encountering the save state being a "joy0" entry from AHK which is unable to be loaded?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...