mGalaxy forum

General Discussions => Need Help? => Topic started by: davhuit on August 13, 2013, 04:01:12 PM

Title: Mame (AutoIt)
Post by: davhuit on August 13, 2013, 04:01:12 PM
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: (AutoIt) [Select]
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]
<Cmd id="0" name="MAME" value="-rompath &quot;%path&quot; %file%ext %volume -skip_gameinfo -nowindow" />
So maybe it's what I missing?

Thanks a lot.
Title: Re: Mame (AutoIt)
Post by: davhuit on August 14, 2013, 02:31:35 PM
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  ???
Title: Re: Mame (AutoIt)
Post by: mgalaxy on August 14, 2013, 03:03:28 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: (autoit) [Select]
$PID = Run( $path & $app & ' -rompath' & $CmdLine[1], $path)
Title: Re: Mame (AutoIt)
Post by: davhuit on August 14, 2013, 03:17:49 PM
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: (AutoIt) [Select]
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
Title: Re: Mame (AutoIt)
Post by: Aeliss on August 15, 2013, 04:49:03 AM
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 (http://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine)
Title: Re: Mame (AutoIt)
Post by: davhuit on August 15, 2013, 05:40:15 AM
Like that ?

Code: (AutoIt) [Select]
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]
Error: unknow option: -rompath-rompath
Title: Re: Mame (AutoIt)
Post by: davhuit on August 16, 2013, 02:18:08 AM
I tested several new things and the best I could do is :

Code: [Select]
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.
Title: Re: Mame (AutoIt)
Post by: mgalaxy on August 16, 2013, 09:47:32 AM
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!!
Title: Re: Mame (AutoIt)
Post by: Aeliss on August 16, 2013, 10:50:57 AM
If you use in your xml part

Code: [Select]
<Cmd id="0" name="MAME" value="-rompath &quot;%path&quot; %file%ext %volume -skip_gameinfo -nowindow" />
try with

Code: [Select]
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
Title: Re: Mame (AutoIt)
Post by: davhuit on August 16, 2013, 02:00:00 PM
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 :)
Title: Re: Mame (AutoIt)
Post by: Aeliss on August 17, 2013, 02:51:06 AM
I forget A space I think try with PID = Run( $path & $app & ' ' & $CmdLineRaw )
Title: Re: Mame (AutoIt)
Post by: davhuit on August 17, 2013, 06:46:25 AM
This time it's working, thanks :)

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

Code: (AutoIt) [Select]
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
Title: Re: Mame (AutoIt)
Post by: davhuit on September 08, 2013, 07:36:05 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=vp1gYtm35R8&feature=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?topic=15.msg125#msg125

Maybe it can fix the problem (if it's really related to the command-line window).
Title: Re: Mame (AutoIt)
Post by: Aeliss on September 08, 2013, 09:49:13 AM
Why do you not use "mame64.exe" ? (no dos box with it)
Title: Re: Mame (AutoIt)
Post by: davhuit on September 08, 2013, 10:21:03 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".
Title: Re: Mame (AutoIt)
Post by: davhuit on September 08, 2013, 10:38:18 AM
Seems to work with "MameIU32" though it also open a dosbox at the start, will see if I get the problem again later or not.
Title: Re: Mame (AutoIt)
Post by: Aeliss on September 08, 2013, 01:08:33 PM
You are right, I m trying the official version and the application is just called "mame.exe".

We can try with a command to active mGalaxy in autoit, if your problem is still here.

Code: [Select]
WinActivate ("mGalaxy")
Title: Re: Mame (AutoIt)
Post by: davhuit on September 08, 2013, 01:29:59 PM
I'll post again here later if I notice the same problem with "MameUI" :)