RetroFE forums
General Category => General Discussion & Help => Topic started by: makaveeti on June 20, 2017, 12:59:18 AM
-
Hi guys,
I'm using RetroFE for windows. I've configured mame and my mame roms in RetroFE. With default launcher settings all works fine.
I made a .bat file to try launch 2 applications 1. ahk (autohotkey) and 2. mame + rom however the roms will not launch from RetroFE. The log file doesn't show any errors.
contents of launcher file -
executable = emulators\MAME\mame64.bat
arguments = %ITEM_FILEPATH%
contents of batch file -
@echo off
pushd "D:\Emulators\RetroFE080\emulators\autohotkey"
start ahk.exe mame.ahk
pushd "D:\Emulators\RetroFE080\emulators\Mame"
mame64.exe %1
I've made .bat files (coded to run several programs) for my windows games in RetroFE and they all work fine.
I tested the above code with Emulation Station for windows and it works fine. Feels like the item_filepath is not being passed through in RetroFE.
What am I doing wrong?
-
try adding quotes like below
executable = emulators\MAME\mame64.bat
arguments = "%ITEM_FILEPATH%"
or try
executable = emulators\MAME\mame64.bat
arguments = "%ITEM_NAME%"
Or you could just use your ahk script to launch mame. Compile the code and point your launcher to the ahk executable. Be sure to use
RunWait, mame64.exe %1%
not
Run, mame64.exe %1%
the latter will cause RetroFE to gain focus again because it will assume the ahk executable is the emulator and as soon as it closes RetroFE will gain focus leaving your game running in the background. The your launcher would be something like this
executable = emulators\MAME\mame.exe <-- Compiled ahk script
arguments = "%ITEM_NAME%"
If you need help with the ahk code I can help you out. Just post your code
-
MAME doesn't use the filename+path for execution; just the game name. As such, %ITEM_NAME% is indeed the variable to use rather than %ITEM_FILEPATH%.
Sent from my SM-G920F using Tapatalk
-
@pieter - I tried both %ITEM_NAME% and %ITEM_FILEPATH% with and without quotes however this doesn't work.
@dustind900 - I'm not sure how I would go about adding the code to my AHK script. The script it designed to exit mame when I hold button9 on my gamepad for 2 seconds. I've pasted the code for the script below:
Joy9::
KeyWait,Joy9,T2 ;wait 2 seconds for release key
If (ErrorLevel) ;more than 2 sec have passed
{
Process, Close, mame64.exe
Exitapp
}
Return
I'd like to add that running the .bat file manually from the command prompt (i.e. start command prompt, mame64.bat gamename) works ok but it doesn't when enacted from RetroFE.
-
Would you mind attaching your log.txt?
Sent from my SM-G920F using Tapatalk
-
Sure. I launched RetroFE, Tried the game Crude Buster (cbuster) and then manually exited from RetroFE.
-
Ok, and launching
emulators\MAME\mame64.bat "cbuster"
directly from the command line does work?
-
Yes it works manually directly from the command line. It launches both the AHK script and the game as per the code in the bat file.
-
pushd "D:\Emulators\RetroFE080\emulators\Mame"
mame64.exe %1
Should that not be
pushd "D:\Emulators\RetroFE080\emulators\Mame\mame64.exe" %1
in stead?
-
Yes it works manually directly from the command line. It launches both the AHK script and the game as per the code in the bat file.
Ok, I will try to free up some time this week to investigate what might be the problem here. I'm not anywhere near my arcade setup at the moment. :)
-
Thanks Pieter.
-
No problem. Can you attach the .bat file as well?
What directory did you launch from whe you used the commandline? I suspect it's a directory issue...
Sent from my SM-G920F using Tapatalk
-
the bat file resides in "emulators\Mame"
when I use the command line manually, i launch from the same directory above.
-
So you launch the script from emulators\Mame when testing from the commandline? Can you try launching from the RetroFE directory using the command I mentioned earlier? I think that Windows is causing some issues with the start directory when launching a .bat file.
Sent from my SM-G920F using Tapatalk
-
Correct and that works.
Trying with the command below results in an error stating the directory name is invalid. I believe this is because the pushd command only applies to directories and not files.
pushd "D:\Emulators\RetroFE080\emulators\Mame\mame64.exe" %1
-
I think that when the .bat file executes MAME, it does so from the RetroFE directory rather than the MAME directory, causing it to not find the mame.ini file, and thus not knowing where to find your roms. I'll need to investigate further. Perhaps it helps if you add a cd command to the MAME directory in your script before launching MAME.
Sent from my SM-G920F using Tapatalk
-
An alternative piece of code for doing the same thing is enclosed below however I get the same result (works from command line but not from retrofe)
D:
CD\emulators\retrofe080\emulators\mame
mame64.exe %1
-
I'll try running some tests tomorrow to see if I can figure it out. 😀
Sent from my SM-G920F using Tapatalk
-
I can confirm that it doesn't work for me either. After a quick search I found that Windows has protections against launching batch files directly from C++ programs, so I'll investigate how to get around that. You say it works from EmulationStation though? I can check their code.
I thought I read that some people had managed to run shutdown scripts via .bat files; I wonder how they managed that then. Did you have any luck launching any .bat file from RetroFE so far?
-
It appears that RetroFE currently uses CreateProcess to launch a program, while EmulationStation uses _wsystem. CreateProcess (https://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx) has an interesting explanation:
"To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file."
So you could give it another try using cmd.exe as executable to let me know if you can solve it that way? If not, then I'll have a look at using _system or _wsystem in stead. I'm not sure why Emb chose CreateProcess, so I'm a bit hesitant to change things there out of fear of breaking other launchers.
See also https://ss64.com/nt/cmd.html
-
I have used the following for bat files in the past: arguments = /C "%ITEM_FILEPATH%"
That launched my bat files fine, however, I have never tried launching multiple items though (ie, an ahk then mame + rom etc)
-
I have used the following for bat files in the past: arguments = /C "%ITEM_FILEPATH%"
That launched my bat files fine, however, I have never tried launching multiple items though (ie, an ahk then mame + rom etc)
Jonah,
Are you using a batch file for Mame? Can you tell me the code from your Mame launcher?
-
I have used the following for bat files in the past: arguments = /C "%ITEM_FILEPATH%"
That launched my bat files fine, however, I have never tried launching multiple items though (ie, an ahk then mame + rom etc)
Jonah,
Are you using a batch file for Mame? Can you tell me the code from your Mame launcher?
Unfotunately not anymore, no.
I use rocketlauncher for pretty much everything now.
An old example (iirc):
executable = ..\roms\pc\cmd.exe
arguments = /C "%ITEM_FILEPATH%"
cmd.exe copied to where the bat file resides but not sure if that was actually needed (again, iirc)
-
All,
I have managed to resolve the issue.
I tweaked the code slightly and copied cmd.exe to the mame emulator folder. Here is what my code looks like now. Hosting the cmd.exe file outside of the mame folder causes it to fail therefore the cmd.exe file must reside in the mame emulator folder.
I'm now able to run an AHK script with MAME :) Thanks to everyone who helped.
Launcher Code
executable = emulators\mame\cmd.exe
arguments = /C mame64.bat "%ITEM_NAME%"
Bat file Code
@echo off
pushd "D:\emulators\retrofe080\emulators\autohotkey"
start ahk.exe mame.ahk
pushd "D:\emulators\retrofe080\emulators\mame\"
mame64.exe %1
-
Glad to see you got your .bat file working. Here is ahk code in case you are curious.
#Persistent
mameEXE := A_ScriptDir "\mame64.exe" ;path to mame64.exe
RunWait, %mameEXE%,,, MAME_PID ;RunWait will wait until the program finishes before continuing
Exitapp
Joy9::
KeyWait, Joy9, T2 ;wait 2 seconds for release key
if (ErrorLevel) ;more than 2 sec have passed
Process, Close, %MAME_PID% ;close MAME using the Process ID we got from the RunWait command
return
-
Glad to see you got your .bat file working. Here is ahk code in case you are curious.
#Persistent
mameEXE := A_ScriptDir "\mame64.exe" ;path to mame64.exe
RunWait, %mameEXE%,,, MAME_PID ;RunWait will wait until the program finishes before continuing
Exitapp
Joy9::
KeyWait, Joy9, T2 ;wait 2 seconds for release key
if (ErrorLevel) ;more than 2 sec have passed
Process, Close, %MAME_PID% ;close MAME using the Process ID we got from the RunWait command
return
Thanks dustind900. This will be very useful to me at some point. I'll test the code tonight. Just to clarify I'm assuming the script launches MAME auotmatically and continues running in the background waiting for me to hold joy9 for 2 seconds?
-
Yes sir
Sent from my LG-H950 using Tapatalk
-
Yes sir
Sent from my LG-H950 using Tapatalk
In that case the above is certainly a sexy piece of code especially for an amateur coder like me :D I'll test tonight and feedback results.
-
Glad to see you got your .bat file working. Here is ahk code in case you are curious.
#Persistent
mameEXE := A_ScriptDir "\mame64.exe" ;path to mame64.exe
RunWait, %mameEXE%,,, MAME_PID ;RunWait will wait until the program finishes before continuing
Exitapp
Joy9::
KeyWait, Joy9, T2 ;wait 2 seconds for release key
if (ErrorLevel) ;more than 2 sec have passed
Process, Close, %MAME_PID% ;close MAME using the Process ID we got from the RunWait command
return
I've tried this in a standalone ahk exe so far and it executes mame just fine. Can you incorporate the passing of the rom file into the code too please? I think you mentioned earlier that its %1 or %1%.
Thanks.
-
Sorry about that.
#Persistent
/*
Info regarding ahk parameters
https://autohotkey.com/docs/Scripts.htm#cmd
*/
if 0 < 1 ;exit script if no parameters were passed
ExitApp
mameEXE := A_ScriptDir "\mame64.exe" ;path to mame64.exe
RunWait, %mameEXE% %1%,,, MAME_PID ;RunWait will wait until the program finishes before continuing
Exitapp
Joy9::
KeyWait, Joy9, T2 ;wait 2 seconds for release key
if (ErrorLevel) ;more than 2 sec have passed
Process, Close, %MAME_PID% ;close MAME using the Process ID we got from the RunWait command
return
Launcher
executable = emulators\MAME\mame.exe
arguments = %ITEM_NAME% ; quotes aren't needed because there are no spaces in mame roms
-
dustind900 - that works perfectly. I didn't think it was possible to automate the running of exe files without pressing the programmed hotkey first.
This is brilliant :) Thanks very much man.
I have a question about translating a vbs script I created to alt+enter upon the launch of a windows game. Perhaps you can help me translate it into an AHK script. I'll PM you the details.
-
To all,
Similar problem.... Calling mame from a batch works perfectly..
mame64.exe %1
What I would like to do is use %1 for other purposes.
So I am assuming that %1 is the whole path/filename/extension for the rom
Just calling echo %1 is not doing anything. (trying to show what the whole variable is)
I would like to set another variable (%2) to the whole path/filename (no extension ( .zip) )
so i can use it to call .wavs/.avis etc
If %1 is not the whole file/path etc how can I add %ITEM_NAME% to the bat also?
Apologies if this is slightly off topic for this thread, thanks in advance.