Mame (AutoIt)

Get answers to questions about using mGalaxy.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Okay, so now, I'm trying to do a AutoIt script for Mame.

I know I can assign a key to quit, but if I can, I would rather use the same combo key on xpadder to close all the emulators (will be easier to remember).

Right now, I'm using the combo LB+click on the right analog stick to emulate the ESC key on xpadder, and can quit Final Burn Alpha (and others emulators which use the ESC key to quit) this way (right analog stick click, without LB, is configured to reset in those emulators).

Until now, I had mapped the right analog stick click in Mame to do the quit button, but if I can use an AutoIt script, I will then be able to use that stick to do reset, which would also be cool)

I tried Mame in command line and it only require : "Mame nameoftherom" (no .zip needed, but it also works when you put a .zip extension anyway) so I tried to use the Model 2 script one, but Mame don't start with it, which is pretty weird.

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] == 1 Then
    $PID = Run( $path & $app & ' ' & $CmdLine[1], $path)
    While 1
          Sleep(100)
    WEnd
EndIf
Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc
I saw this in the xml file :

Code: Select all

 <Cmd id="0" name="MAME" value="-rompath "%path" %file%ext %volume -skip_gameinfo -nowindow" />
So maybe it's what I missing?

Thanks a lot.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

I tried another script, Project64 2.1 one (though Mame don't require any quotes) but same, Mame don't run with it, seems weird  ???
User avatar
mgalaxy
Administrator
Administrator
Posts: 1189
Joined: Tue Dec 05, 2006 7:46 pm

As you can see in the "systems.xml" there's a '-rompath' which is passed to the command line.
Try to add it to your AutoIt script, like this:

Code: Select all

$PID = Run( $path & $app & ' -rompath' & $CmdLine[1], $path)
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Ah, as it was working in command line without it, I thought it was optional.

I tested with your line and it still don't work ???. mGalaxy say "launching game" but it stay on the games list window.

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] == 1 Then
    $PID = Run( $path & $app & ' -rompath' & $CmdLine[1], $path)
    While 1
          Sleep(100)
    WEnd
EndIf
Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc
Last edited by davhuit on Wed Aug 14, 2013 8:23 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

You still have 2 errors.

$CmdLine[1] = first param, so you pass the param "-rompath" and  only this one, try $CmdLineRaw (contains the entire command line)

$CmdLine[0] == 1 : in your case you have more than 1 param so better use
$CmdLine[0] <>0 or $CmdLine[0] > 0

More infos here http://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Like that ?

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] > 0 Then
    $PID = Run( $path & $app & ' -rompath' & $CmdLineRaw, $path)
    While 1
          Sleep(100)
    WEnd
EndIf
Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc

Mame give me the following error :

Code: Select all

Error: unknow option: -rompath-rompath
Last edited by davhuit on Thu Aug 15, 2013 1:55 pm, edited 1 time in total.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

I tested several new things and the best I could do is :

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] > 0 Then
    $PID = Run( $path & $app & ' -rompath')
    While 1
          Sleep(100)
    WEnd
EndIf
Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc
which now output this error :

Error: Option -rompath excepted a parameter.

No more "-rompath-rompath" (twice the same line) but it still don't work.
Last edited by davhuit on Fri Aug 16, 2013 7:45 am, edited 1 time in total.
User avatar
mgalaxy
Administrator
Administrator
Posts: 1189
Joined: Tue Dec 05, 2006 7:46 pm

I'll help you as soon as I'm back from my holidays. I've tried to help with my first reply to your post...but it was done quickly on my phone. I'll take some times to reply you efficiently in 2-3 days!!
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

If you use in your xml part

Code: Select all

<Cmd id="0" name="MAME" value="-rompath "%path" %file%ext %volume -skip_gameinfo -nowindow" />
try with

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] > 0 Then
    $PID = Run( $path & $app & $CmdLineRaw )
    While 1
          Sleep(100)
    WEnd
EndIf

exit 0

Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Yeah, I use the same xml infos.

With this version, it stay on mGalaxy main screen (no more console with the error).

@mGalaxy : There's no hurry, have a great holliday :)
Last edited by davhuit on Fri Aug 16, 2013 7:07 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

I forget A space I think try with PID = Run( $path & $app & ' ' & $CmdLineRaw )
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

This time it's working, thanks :)

Here's the whole script, if someone else need it one day :

Code: Select all

HotKeySet("{ESC}", "Terminate")
$path = "F:\Jeux PC [Downloads]\Emulation\mame0149b\"
$app = "mame.exe"

If $CmdLine[0] > 0 Then
    $PID = Run( $path & $app & ' ' & $CmdLineRaw )
    While 1
          Sleep(100)
    WEnd
EndIf

exit 0

Func Terminate()
    While ProcessExists ( $PID )
	ProcessClose ( $PID )
    WEnd
    Exit 0
EndFunc 
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

I found a little problem with my script, but it's probably not coming from v5.0, it's probably just that I didn't noticed it before.

Sometimes, when I quit Mame, mGalaxy lost the focus and I have to use ALT-TAB several times to get the focus back.

Here's an example of it in a video : http://www.youtube.com/watch?v=vp1gYtm3 ... e=youtu.be

It often happen when I reset the game, then quit. It seems that the cause would be the command-line window that appear when you start/reset a game (as it's the only emulator which have that "bug" in my list).

Is there a way to fix the focus when I quit Mame by modifying the AutoIt script?

Meanwhile, I'll try that : http://www.mgalaxy.com/forum/index.php? ... 125#msg125

Maybe it can fix the problem (if it's really related to the command-line window).
Last edited by davhuit on Sun Sep 08, 2013 12:39 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

Why do you not use "mame64.exe" ? (no dos box with it)
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

No real reason, just took the first one I found (the official website don't seem to have true windows version : http://mamedev.org/release.html).

But yeah, as I wrote at the end of my previous message, I plan to try a Windows based version to see if the problem come from that.

If someone know whre to find the 0149b version for Windows, I'm interested.

Edit : Okay, it seems the true windows version waqs called "Mame32" (for the 32 bits version) and now renamed "MAMEUI".
Last edited by davhuit on Sun Sep 08, 2013 3:30 pm, edited 1 time in total.
Post Reply