I found this but dont know what to do with it:
#IfWinActive, ahk_class MAME ; MAME
F7:: ; SAVE
Sleep, 30
Send, {F8 Down}
Sleep, 30
Send, {F8 up}
Sleep, 30
Send, {m Down}
Sleep, 30
Send, {m Up}
Sleep, 30
return
F2:: ; LOAD
Sleep, 50
Send, {F9 Down}
Sleep, 50
Send, {F9 up}
Sleep, 50
Send, {m Down}
Sleep, 50
Send, {m Up}
Sleep, 50
return