Jump to content
LaunchBox Community Forums

Launch AHK script before launching MAME


pina

Recommended Posts

17 minutes ago, pina said:

Wauw, I really have to dig very deep to answer you... Let me find out first myself because it's been almost 2 years... 😆 

LOL, sorry. I still haven't found a way to do this yet. Ie. have wiimote work as light gun in Dolphin for wii games and Mame. Can't justify any other purchases as the moment to improve light gun play so hoping this can get me through for a bit.

Link to comment
Share on other sites

1 hour ago, thefritz11 said:

LOL, sorry. I still haven't found a way to do this yet. Ie. have wiimote work as light gun in Dolphin for wii games and Mame. Can't justify any other purchases as the moment to improve light gun play so hoping this can get me through for a bit.

So here’s what I found out, this comes in handy whenever I need to reinstall everything again one day… :D

1. I created anothe mame instance in my file explorer, mame lightgun (a copy of my existing mame folder)
2. I created an ahk script, then compiled it as an exe file, see below
3. In Launchbox, I created an new emulator, called Mame lightguns. It points to the the exe file of the compiled ahk script we just created for lightgun games
4. All the games in the playlist of Launchbox, called Lightgun Games, will be launched by my newly created Mame lightgun-emulator

And finally, the script was this:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir C:\Program Files\AutoHotkey  ; Ensures a consistent starting directory.
SetWorkingDir D:\retro\emulators\mame light\mame64.exe

Run, C:\Program Files\Touchmote\Touchmote.exe,  C:\Program Files\Touchmote
Sleep, 3000
RunWait, D:\retro\emulators\mame light\mame64.exe -keyboardprovider dinput %1%
;Sleep, 2000

Loop, 2
{
;MsgBox, Iteration number is %A_Index%.  ; A_Index will be 1, 2, then 3
WinClose, ahk_exe Touchmote.exe
}

the script runs touchmote first, then wait 3 seconds before launching mame. When quitting the game, it closes touchmote too.

I hope it solves your problem

Edited by pina
Link to comment
Share on other sites

22 minutes ago, pina said:

So here’s what I found out, this comes in handy whenever I need to reinstall everything again one day… :D

1. I created anothe mame instance in my file explorer, mame lightgun (a copy of my existing mame folder)
2. I created an ahk script, then compiled it as an exe file, see below
3. In Launchbox, I created an new emulator, called Mame lightguns. It points to the the exe file of the compiled ahk script we just created for lightgun games
4. All the games in the playlist of Launchbox, called Lightgun Games, will be launched by my newly created Mame lightgun-emulator

And finally, the script was this:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir C:\Program Files\AutoHotkey  ; Ensures a consistent starting directory.
SetWorkingDir D:\retro\emulators\mame light\mame64.exe

Run, C:\Program Files\Touchmote\Touchmote.exe,  C:\Program Files\Touchmote
Sleep, 3000
RunWait, D:\retro\emulators\mame light\mame64.exe -keyboardprovider dinput %1%
;Sleep, 2000

Loop, 2
{
;MsgBox, Iteration number is %A_Index%.  ; A_Index will be 1, 2, then 3
WinClose, ahk_exe Touchmote.exe
}

the script runs touchmote first, then wait 3 seconds before launching mame. When quitting the game, it closes touchmote too.

I hope it solves your problem

So---I have done a few basic scripts for pause screens etc. but compiling as an .exe file is close to another language to me. That is not something you can share is it?

Link to comment
Share on other sites

2 hours ago, thefritz11 said:

So---I have done a few basic scripts for pause screens etc. but compiling as an .exe file is close to another language to me. That is not something you can share is it?

I just gave you the script… it’s autohotkey script and you just have to create a .ahk file, then compile it to an exe. It’s just a click to do so. I refer you to the tutorial of AHK and you’ll understand

Link to comment
Share on other sites

15 hours ago, thefritz11 said:

So---I have done a few basic scripts for pause screens etc. but compiling as an .exe file is close to another language to me. That is not something you can share is it?

To compile the AutoHotkey script you need to have the full AutoHotkey program installed on your system.  

Alternately, when you create your 'new emulator', instead of pointing to a compiled AHK script (script_name.exe), you can use the AutoHotkey executable that comes bundled with LaunchBox and directly use your uncompiled script_name.ahk.

Here's a little how-to do this.  See the part "Add the "new" Emulator:".   (You can skip the end part regarding the Startup Screen.)

 

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...