Jump to content
LaunchBox Community Forums

Recommended Posts

Posted (edited)

If this is not the correct section, any of the mods are welcome to move it to the correct areas if necessary.

I was having an issue getting ShaderGlass to work with MAME because ShaderGlass wasn't populating on top of the MAME window. This took me a long time to figure out so I wanted to share my solution incase anyone else was having a similar issue.

Disclosure: I'm not very good at coding so I used AI for assistance. I tested this over several iterations. It works for me so hopefully its helpful for others as well.

Also, for reference, I used the code in this post to get started.

The code accomplishes the following:

  • It prevents windows from flashing while MAME and ShaderGlass load
  • It's timed dynamically so it waits until BOTH MAME & ShaderGlass are fully up and running before closing so it's unnecessary to edit this script per game
  • It forces MAME to open in windowed mode and prevents the top menu border from being displayed
  • It launches ShaderGlass on top of MAME and loads the correct profile
  • It attempts to bypass any MAME warning/nag screens
  • It moves the mouse off screen so it's not shown during gameplay
  • It closes ShaderGlass & MAME when the ESC key is pressed

Edit this code to accommodate your set up. The finished code should replace the code in the Running Script section within the MAME Emulation menu of LaunchBox.

Happy gaming :)
 

#Persistent

; 1. DISPLAY BLACK CURTAIN IMMEDIATELY AND HIDE/PARK MOUSE
Gui, +AlwaysOnTop -Caption +ToolWindow
Gui, Color, Black
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%
MouseMove, A_ScreenWidth, A_ScreenHeight, 0

; 2. Launch ShaderGlass in the background once the game starts
Run, "C:\_LaunchBox\-Misc\Programs\Shaders\Backup Files\ShaderGlass\ShaderGlass.exe" -f "C:\_LaunchBox\-Misc\Programs\Shaders\Backup Files\ShaderGlass\Profile.sgp"

; 3. Dynamically wait until BOTH MAME and ShaderGlass are fully up and running
Loop
{
    IfWinExist, ahk_exe mame.exe
    {
        IfWinExist, ahk_exe ShaderGlass.exe
        {
            break
        }
    }
    Sleep, 100
}

; 4. Style and maximize MAME seamlessly behind the curtain
WinGet, minMax, MinMax, ahk_exe mame.exe
WinGet, style, Style, ahk_exe mame.exe
if (minMax = -1 || (style & 0xC40000))
{
    WinSet, Style, -0xC40000, ahk_exe mame.exe
    WinMaximize, ahk_exe mame.exe
    WinMove, ahk_exe mame.exe, , 0, 0, A_ScreenWidth, A_ScreenHeight
}

; 5. Automatically bypass MAME warning/nag screens behind the curtain
WinWait, ahk_exe mame.exe,, 60
if !ErrorLevel
{
    WinWaitActive, ahk_exe mame.exe,, 30
    if !ErrorLevel
    {
        Sleep, 500
        SetKeyDelay, 125, 50
        Send, {space 3}
    }
}

; Brief stabilization pause behind the curtain
Sleep, 300

; 6. Drop the curtain, park the mouse in the corner again, and bring MAME to the front
MouseMove, A_ScreenWidth, A_ScreenHeight, 0
Gui, Destroy
WinActivate, ahk_exe mame.exe

return

; 7. When Escape is pressed, close ShaderGlass and MAME cleanly
$Esc::
    Process, Close, ShaderGlass.exe
    Process, Close, mame.exe
    ExitApp
return
Edited by Special T

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