Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

4 hours ago, Xngears said:

The only thing I'm wondering now is if the script could be edited so that instead of hitting ESC, I can hit a specific button instead. I'm using the Dualsense controller and I've got the mic button mapped to close active windows (thus, close the emulator). Any way I could have that button be the Dolphin+DS4 killer?

I could probably also use something like reWASD to map ESC to the button, but I'm looking for whatever is the simplest method.

You can already do this with DS4Windows.

698328181_Schermopname(50).thumb.jpg.1d89f047d466b55b5d94366b11b7ffe0.jpg

Create a new profile for your controller or edit an existing one.

1704437364_Schermopname(51).thumb.jpg.a0f6b5196a7fc1c7d4f690fbc7cb2c3c.jpg

Go to the [Special Actions] tab and click [New Action].

1260543967_Schermopname(52).thumb.jpg.8a871fee7738a1574e3d93eef172d2e0.jpg

Tick [Mute] (your Mic. button) and at [Select an Action] select [Press/Toggle Key]. Then on the on-screen keyboard click the [Escape] key.

1414506034_Schermopname(53).thumb.jpg.000b4a4f2b82c9f6b472b99e29915ca9.jpg

Give your special action a name > Save.

1779193524_Schermopname(54).thumb.jpg.6f52c6190ffc381bf53821efdd47996a.jpg

If you want you can create an auto-profile that automatically applies when you start Dolphin.

Link to comment
Share on other sites

12 hours ago, Your_Friendly_AI_Overlord said:

You can already do this with DS4Windows.

698328181_Schermopname(50).thumb.jpg.1d89f047d466b55b5d94366b11b7ffe0.jpg

Create a new profile for your controller or edit an existing one.

1704437364_Schermopname(51).thumb.jpg.a0f6b5196a7fc1c7d4f690fbc7cb2c3c.jpg

Go to the [Special Actions] tab and click [New Action].

1260543967_Schermopname(52).thumb.jpg.8a871fee7738a1574e3d93eef172d2e0.jpg

Tick [Mute] (your Mic. button) and at [Select an Action] select [Press/Toggle Key]. Then on the on-screen keyboard click the [Escape] key.

1414506034_Schermopname(53).thumb.jpg.000b4a4f2b82c9f6b472b99e29915ca9.jpg

Give your special action a name > Save.

1779193524_Schermopname(54).thumb.jpg.6f52c6190ffc381bf53821efdd47996a.jpg

If you want you can create an auto-profile that automatically applies when you start Dolphin.

Excellent, this worked. Thank you so much for all the help.

Link to comment
Share on other sites

Hey everyone,

I have a question about a script. For my PS1 platform, I want to use a real dual shock controller with a usb adapter. In order to get vibration support, I need a program called XOutput to simulate an Xbox controller in Retroarch. I would like that XOutput automatically starts when I launch a PS1 game and automatically closes when I exit the game and retroarch closes (controller shortcut).

I managed to get the first thing going. When I start a PS1 game, XOutput launches, too. This is my script:

run, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput\XOutput.exe, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput, min

 

However, I struggle with the second part. Whenever I exit retroarch, I cannot get XOutput to shut down. I've tried just about anything I could find in this thread or elsewhere. Nothings seems to work. Can you tell me how to do this? I've even tried creating a batch file that kills XOutput and running that when I exit Launchbox with a controller.

This was my last try that didn't work:

$Esc::
{
Run, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput\KILL.lnk, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput
}

Edited by SiriusVI
Link to comment
Share on other sites

13 minutes ago, SiriusVI said:

Whenever I exit retroarch, I cannot get XOutput to shut down.

I think what happens is when you hit Escape, it shuts down RA and essentially kills the emulators Running Script.  But I also think that if the Escape sequence is set to close the emulator in addition, it works.  So you want your escape sequence to Kill XOutput and THEN exit RA.

$Esc::
{
   Run, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput\KILL.lnk, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput
   WinClose, ahk_exe retroarch.exe
}

If you read the previous page (or 2) in this thread, you'll see the XBox simulator thingys are a right p.i.t.a. to close!  I don't use them, so can't do any hands on testing.

I'd say 1st, make sure your KILL.bat (.lnk) does indeed work.  Then try the above suggestion.  As you'll read on the previous page, it was said that it worked without the "$" in front of esc, but not with. So try both ways.  You might also find that one of the other programs being used will do what you need.  Then just peek at their 'answers'. ;) 

  • Like 1
Link to comment
Share on other sites

OMG, "Esc" without the "$" worked. XOutput shuts down now.

This was quite the Odysee from getting the Dual Shock to finding the right adapter to trying different drivers that support vibration, to finding an easy to us Xinput wrapper to making it start with retroarch and finally make it shut down with retroarch.

But alas, I can finally play PS1 games with an OG Dual Shock and vibration support. This is really cool =D.

 

EDIT:

That batch is not needed now, everything works using this simple script:
 

run, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput\XOutput.exe, M:\LaunchBox\Emulators\RetroArch - Original Controllers (PSX)\XOutput, min

Esc::
{
   WinClose, ahk_exe XOutput.exe
}

Edited by SiriusVI
  • Game On 1
Link to comment
Share on other sites

Hello, new to making scripts for Launchbox i am trying to launch XArcade Xinput with a few of my games and for the life of me i cannot figure out how to make the scripts work. I found these on a website but they dont go into much detail other than saying that you have to make a .bat and .exe. any help would be appreciated 

 

 

 

 

$Esc::
{
Process, Close, XArcade_XInput.exe
}

Escape::
Send !{f4}

if WinExist("LaunchBox Game Startup")
{
WinActivate
WinWaitClose, LaunchBox Game Startup
}

if WinExist("LaunchBox")
{
WinActivate
}

if WinExist("LaunchBox Big Box")
{
WinActivate
}

ExitApp
return
 

 

 

 

 

 

 

@echo off

   start auto_close_xinput.exe
   start XArcade_XInput.exe --skip-ui
   
@echo on
 

Link to comment
Share on other sites

  • 3 weeks later...

Hello,
I have configured as Running Script the following AHK

F12::
{
    Process, Close, Retroarch.exe

    if WinExist("LaunchBox")
    {
        WinActivate
        WinActivate, LaunchBox Game Startup
    }

    if WinExist("LaunchBox Big Box")
    {
        WinActivate
        WinActivate, LaunchBox Game Startup
    }


}

When I run it from launchbox if I have any window in foreground when I press F12 it closes correctly retroarch and launchbox gets the focus.

But when I run it from BigBox, it doesn't get the BigBox focus, on the other hand if I run it from outside AHK the same BigBox script does get the focus.

Does anyone know what can be happening so that from BigBox the WinActivate works correctly?

Translated with www.DeepL.com/Translator (free version)

Link to comment
Share on other sites

57 minutes ago, Aiwer said:

Does anyone know what can be happening so that from BigBox the WinActivate works correctly?

Both LaunchBox (LB) and BigBox (BB) should be regaining focus when you exit a game, automatically.  But since it's not doing that for you, for some reason...

Move the closing emulator part to the last line.  When LB/BB sees that the emulator has been closed, the "Running Script" essentially gets abandoned.  Also, use the WinClose method rather than Process, Close.  It's a 'nicer' way of closing an application.

2 lines can replace 10 lines of If;)   Also, using WinActivateBottom will grab the LB/BB GUI in case Startup/Shutdown screens.

F12::
{
   WinActivateBottom,  ahk_exe LaunchBox.exe
   WinActivateBottom,  ahk_exe BigBox.exe
   WinClose, ahk_exe Retroarch.exe
}

 

Link to comment
Share on other sites

Hi @JoeViking245

The script doesn't work at all, the BigBox screen gets the focus, but it's like frozen, it doesn't play videos, the Joystick doesn't work.

I have to click on it with the mouse to get it to work again, it's pretty weird, I've tried activating the startup screens and removing them.

This happens to me very often and I'm just launching retroarch nothing else.
Any suggestions?

Link to comment
Share on other sites

17 minutes ago, Aiwer said:

The script doesn't work at all, the BigBox screen gets the focus, but it's like frozen, it doesn't play videos, the Joystick doesn't work.

I have to click on it with the mouse to get it to work again, i

Then Bigbox doesnt have focus, especially if mouse clicking on it then works.

Link to comment
Share on other sites

50 minutes ago, Aiwer said:

Hi @JoeViking245

The script doesn't work at all, the BigBox screen gets the focus, but it's like frozen, it doesn't play videos, the Joystick doesn't work.

I have to click on it with the mouse to get it to work again, it's pretty weird, I've tried activating the startup screens and removing them.

This happens to me very often and I'm just launching retroarch nothing else.
Any suggestions?

As stated, both LB and BB should just regain focus when you exit.  Have you tried reassigning the "Quit RetroArch" key in RetroArch itself to F12? Then you wouldn't (shouldn't) need the Running Script at all.  Open RetroArch, go to SettingsInputHotkeys, and reassign Quit RetroArch.  (Just in case it's not already, make sure Confirm Quit is set to Off.)

During game play, are you Alt-Tabbing to another window?  That could screw up the window order making WinActivateBottom grab the wrong window.  BB could still be "Active", but may not "have focus".

Link to comment
Share on other sites

Confirmed that the confirmation quit is disabled, I have mapped a joystick button to exit retroarch, before I used joytokey to send an ESC now it is direct with a button.

I only have the load game messages active, and randomly I keep losing focus when exiting the game.

If I open mame games that I launch with retroarch and I hit the exit button, in many occasions it works fine, but in some I fail, and this is a problem because I have it in arcade without keyboard and it makes me restart the system.

I don't have any script in the load, I have tried with WinActivateBottom and it doesn't work either, bigbox is the only application that runs, and the only special thing I have is that I use two screens, one for games and another one for marquees.

Link to comment
Share on other sites

17 hours ago, Aiwer said:

the only special thing I have is that I use two screens, one for games and another one for marquees.

That shouldn't be the issue.  I guess maybe backtrack a little and determine what window is taking focus after exiting and game.  After the games exits, if you press and hold Alt and then hit TAB once (while still holding Alt), You'll see all open windows and the Active window will be the left most one.

Link to comment
Share on other sites

I have already seen the problem, when the BigBox window doesn't get the focus, it is because it gets it from the JoytoKey that I use to send the esc key from the joystick 2 to the retroarch to exit.

Is there any way to indicate at the emulator level to run a program on exit, in the style of additional applications that is at the game level?

Or does anyone know how to configure retroarch to assign hotkeys from the jostick 2?

Thank you very much  @JoeViking245 for your advice.

Link to comment
Share on other sites

14 hours ago, Aiwer said:

I have already seen the problem, when the BigBox window doesn't get the focus, it is because it gets it from the JoytoKey that I use to send the esc key from the joystick 2 to the retroarch to exit.

Is there any way to indicate at the emulator level to run a program on exit, in the style of additional applications that is at the game level?

Or does anyone know how to configure retroarch to assign hotkeys from the jostick 2?

Thank you very much  @JoeViking245 for your advice.

I'm 95% sure I've got a "solution" to this but not near computer until tomorrow.

Should work for any emulator that uses the Running AutoHotKey tab.

This is a stolen idea from JayJay LaunchScript plugin so I take no credit for it

Steps

1. Download foucs.ahk (attached) and put in AutoHotKey folder inside Thirdparty folder

2. Open LaunchBox

3a. Right click on a game of the emulator that is causing you an issue

3b. Edit ---- Edit Metadata/Media

4 Click Emulation ------- Edit ------ Running Script

5. Add the following lines to the top of the script

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Run, AutoHotkey.exe "Focus.ahk" "ahk_exe {{{StartupEXE}}}" , %A_ScriptDir%\..\..\ThirdParty\AutoHotkey

(Explanation - This will load the Focus.ahk that you downloaded and pass the name of the emulator to the new AHK. You can put anything else in this Running AutoHotKey Tab but DO NOT put anything about trying to get LaunchBox or BigBox to get focus after emulator closes - you can put hotkeys for closing the emulator if needed plus anything else

I think that there is already some stuff in here from LaunchBox about trying to skip the nag screens - I don't normally have that on mine but sometimes when I go into this tab it glitches out and shows it rather than my stuff.

You can change the "%A_ScriptDir%\..\..\ThirdParty\AutoHotkey" to the actual path where you have the AutoHotKey.exe but this works for portable versions in theory- if it doesn't work or you get an error that the Focus.ahk cannot be found then put the actual path in as I haven't tested on many systems eg C:\Users\User1\LaunchBox\ThirdParty\AutoHotkey but adapted to your actual pathway)

6. Save your changes with OK button

7. Launch the game and give it a try.

The focus.ahk basically does the following

Waits for emulator to open

Waits for emulator to close

Then looks for Start-up/Close-down screens, LaunchBox/BigBox and depending what exists activates them in a nice order - the cherry on the cake that stops the whole BigBox sometimes not having focus when this is done - is a simple mouse click in the bottom right corner at the very end.

Good luck

Focus.ahk

Edited by Kiinkyfoxx
Adding the ahk and description
  • Like 1
Link to comment
Share on other sites

42 minutes ago, Sbaby said:

Hi . I would like to start some applications and services automatically when launchbox starts. Is it possible? Or am I obliged to create an autohotkey ?

It's not possible through LaunchBox itself, but you can create a batch file to start your apps and start LaunchBox.  Something like

@echo off
start "" D:\MyApps\App1.exe
start "" D:\MyApps\App2.exe
start "" D:\LaunchBox\LaunchBox.exe

Or do the same thing using an AHK script.

  • Thanks 1
Link to comment
Share on other sites

  • 3 weeks later...

Hi, for some strange reason it happens that while playing mame I still hear the sound of the launchbox or bigbox game preview video in the background. I found this solution with this "SoundVolumeView" application by starting this ahk when starting mame. In practice, it turns off the windows audio (only of the Bigbox and Launchbox application) during mame sessions. This works very well but I would like to ask if possible to add a native launchbox option to do this with all games. Is useful

Link :

https://www.nirsoft.net/utils/sound_volume_view.html

 

Ahk Scripts :

run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /Mute LaunchBox
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /Mute BigBox

Process, WaitClose, mame.exe

run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute LaunchBox
run, "M:\Giochi\Utility\Launchbox\ThirdParty\SoundVolumeView\SoundVolumeView.exe" /UnMute BigBox

Link to comment
Share on other sites

When I press Escape Duckstation automatically closes the game window and creates a save game which is great. However, Duckstation won't close itself afterwards. Now I need a script to do the following when I press the Esc button:

Quote

Execute Esc #causes Duckstation to stop the emulation and creates a save game

Wait 2 seconds #Duckstation needs a couple seconds to create the save game

Close Duckstation #kill the process

Does anyone have a script for that?

EDIT: I hate scripting but here's what I came up with and it's working as intended..

$Esc::
{
Send, {Esc}
 sleep, 2000
    Process, Close, {{{StartupEXE}}}
}

Edited by TimmyT
Link to comment
Share on other sites

4 hours ago, TimmyT said:

Duckstation won't close itself afterwards.

Any chance you're pointing to the "qt" executable instead of the "nogui" executable?  

image.png.ce54e9f5ef30771e6a7aa6a63abb1b28.png

The 'nogui' one is what you want to launch via LaunchBox. Then you won't need any script at all.

 

Just an FYI, if later you decide you don't want to create a save game when exiting, run/open the qt version and go to SettingsGeneral Settings and you can uncheck Save State on Exit

image.thumb.png.603e9758a017b316707ef1da4c79b040.png

  • Thanks 1
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...