Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

1 hour ago, tribe fan said:

Nothing special haha.

Sleep, 2000

Send, {F11}

Try putting this in the Running Script section of your melonDS emulator.

SetKeyDelay, -1, 110
Loop
{
   ifwinactive, ahk_exe melonDS.exe
   {
      send {F11}
      break
   }
}

(just in case ;))  Make sure you set "Toggle Fullscreen" to F11 in the General Hotkeys section under ConfigInput and hotkeys in the emulator itself.

Edited by JoeViking245
Revised script (improved, cleaned up)
Link to comment
Share on other sites

31 minutes ago, tribe fan said:

is there an easy way to open and close an Xpadder profile upon launching and exiting an emulator? I can't seem to find an easy way to do that.

Running Script 

Run, "D:\Utils\XPadder\xpadder.exe" -loadme "D:\Utils\XPadder\my_profile.ext"
Process, Wait, myEmulator.exe
while winExist("ahk_exe myEmulator.exe")
	sleep 700
WinClose, ahk_exe xpadder.exe

It may be apparent that I know nothing about Xpadder.  So adjust:

  • Line 1 - the Path(s), executable and command-line to load your profile
  • Line 2 - the actual emulator you're setting this up for (it's probably not "myEmulator.exe")
  • Line 3 - same thing as Line 2
  • Line 5 - the executable for xpadder as necessary.

The last line (5) may or may not work.  You may need to swap it with an exit emulator hotkey that includes xpadder.

$esc::
{
   WinClose, ahk_exe xpadder.exe
   WinClose, ahk_exe myEmulator.exe
}

If instead of closing xpadder you want to load a different (default?) profile, change the 1st WinClose line to something similar to Line 1 above.

 

Not tested, but JoeViking approved.

Link to comment
Share on other sites

Thanks again! I went for a more forceful method of closing Xpadder since the WinClose method wasn't working for me. Here's my full script if anyone else is trying to accomplish the same:

SetTitleMatchMode, 2
SetKeyDelay, 0, 50

Loop
{
   ifwinactive, ahk_exe melonDS.exe
   {
      sleep 2000
      send {F11}
      break
   }
}
Run, "G:\Gaming\Utilities\Xpadder\Profiles\melonDS\Xbox 360.xpadderprofile"
Process, Wait, melonDS.exe
while winExist("ahk_exe melonDS.exe")
	sleep 700
$esc::
{
   Process,Close,Xpadder.exe
   WinClose, ahk_exe melonDS.exe
}

I really love the melonDS emulator, but it's not very customizable. There's no way to map analog sticks to mouse movements (hence the need for an Xpadder profile). This script is doing exactly what I'm needing. Much appreciated again!

  • Game On 1
Link to comment
Share on other sites

On 1/27/2022 at 8:37 AM, JoeViking245 said:

I'm afraid I can't really help with this as I've never used the Universal Control Remapper program.  

Is this opening a Command Prompt Window?  When this happens, if you use {Alt}+{Tab}, can you switch to the game and then play?  

Maybe you can still help me. Basically you can launch a UCR profile with a command line argument. 
 

-p, —profile: UCR.exe -p “Some profile”

 

I want to activate a profile when launching retroarch or steam games  

I am not sophisticated enough to know how or where to place this argument 

 

Edited by jivemd
Link to comment
Share on other sites

9 hours ago, jivemd said:

I want to activate a profile when launching retroarch or steam games  

If you have a 'generic' profile you want to load for all Retroarch games, you can edit your Retroarch emulator and in the Running Script section you'd have something like

Run, "D:\utils\ucr\UCR.exe" -p "full/path/to/Some profile.ext"

Change the path to your UCR.exe and the path to 'Some Profile'.  And keep both those paths in quotes as shown.

The potential problem here is, if the profile needs to be fully loaded BEFORE Retroarch starts, it may not work because these 2 (RA and the script) launch somewhat simultaneously.  But this method may still work.

 

For individual RA games and Steam games, you can get the profile to load 1st before the 'emulator'.  Do this by editing the game(s) and adding an Additional Application and telling it to Automatically Run Before Main Application.

image.thumb.png.4ed8b837838a4dd9045e992b938baf28.png

Give it a name.  Browse to where your UCR.exe is located. Put in the command line, changing the path to YOUR actual profile (and leave the quotes). Check Automatically Run Before...

Link to comment
Share on other sites

7 minutes ago, JoeViking245 said:

If you have a 'generic' profile you want to load for all Retroarch games, you can edit your Retroarch emulator and in the Running Script section you'd have something like

Run, "D:\utils\ucr\UCR.exe" -p "full/path/to/Some profile.ext"

Change the path to your UCR.exe and the path to 'Some Profile'.  And keep both those paths in quotes as shown.

The potential problem here is, if the profile needs to be fully loaded BEFORE Retroarch starts, it may not work because these 2 (RA and the script) launch somewhat simultaneously.  But this method may still work.

 

For individual RA games and Steam games, you can get the profile to load 1st before the 'emulator'.  Do this by editing the game(s) and adding an Additional Application and telling it to Automatically Run Before Main Application.

image.thumb.png.4ed8b837838a4dd9045e992b938baf28.png

Give it a name.  Browse to where your UCR.exe is located. Put in the command line, changing the path to YOUR actual profile (and leave the quotes). Check Automatically Run Before...

Thank you for this. I did happen to try this exact thing. What happens is that UCR opens and loads the correct profile but freezes the emulator in the process. And I can’t get the emulator going again. It’s not paused. Alt-tab does nothing. 

I am now looking to see if there is a way that I can have UCR already open( I’ll just open it at startup) and then have LaunchBox load a specific profile for a game or emulator. I know that you can use the command argument to load a profile. I just don’t know if I can do that within LaunchBox. 

According to the developers of UCR, you can switch between all your profiles with just a command argument. 

Link to comment
Share on other sites

12 minutes ago, jivemd said:

I am now looking to see if there is a way that I can have UCR already open( I’ll just open it at startup)

If say you double-click on UCR.exe so that it loads (hanging out in the background?) and then start LB... then launch a game [with one of the above methods to load a profile], does it still freeze the emu?

If not, you can just have a batch file that will start UCR and then start LB.

@echo off
f:
cd "F:\Misc\UCR"
start "" "UCR.exe"

cd "F:\LaunchBox"
start "" LaucnhBox.exe

Adjust the drives and path accordingly.

Link to comment
Share on other sites

11 minutes ago, JoeViking245 said:

If say you double-click on UCR.exe so that it loads (hanging out in the background?) and then start LB... then launch a game [with one of the above methods to load a profile], does it still freeze the emu?

If not, you can just have a batch file that will start UCR and then start LB.

@echo off
f:
cd "F:\Misc\UCR"
start "" "UCR.exe"

cd "F:\LaunchBox"
start "" LaucnhBox.exe

Adjust the drives and path accordingly.

I can open UCR easily any time. Once you open UCR, the controller profile is not started until you tell it to start. So I can easily start a profile while in the LaunchBox space. It loads my virtual Xbox controllers and then I can easily load any game. 
if however I tell LaunchBox to open ucr and load a profile as a script to load before the main application..UCR still works and my controllers load but ( excuse my naivety) the opening of UCR at that moment seems to dominate the computer. It freezes the emulator and the emulator won’t move forward. 
so the 2 things I thought may work

1) having UCR already open in the background. But not loading a profile until I enter a specific game. But I’m not sure how to code that. 
2) opening UCR, loading a profile through LaunchBox script BUT having a long enough delay to let that settle and then open the emulator. I tried increasing a sleep time but it does not seem to matter. The emulator opens immediately with UCR. Again, I’m sure you know of a simpler way. 
 

thanks again for your thoughts. I appreciate your time. 

Link to comment
Share on other sites

Hello, I have tried some scripts I found on here but I am still trying to tweak them.

I am using X360CE for my G29 wheel.  For certain emulators that I need X360,  I would like it to load in the background while my emulator loads or minimized.  Its currently windowed on top of my emulator so I need to click off it with my mouse to play.  Also I would like it to close when I close the emulator.

 

Example of my script for Yuzu.

Run, "C:\Users\Gerry\Desktop\X360CE\X360CE.exe"
Process, Wait, Yuzu.exe
while winExist("ahk_exe Yuzu.exe")
    sleep 700

Link to comment
Share on other sites

1 hour ago, gerrymarsh87 said:

I would like it to load in the background

 

1 hour ago, gerrymarsh87 said:

Also I would like it to close when I close the emulator.

 

I assume this in your Running Script section of the emulator.  Adding a couple of commas and "Min" should start x360ce minimized. 

Normally you could add the WinClose yuzu after the WinWait.  That won't work here because as soon as the emulator (yuzu) exits, this script is abandoned.  WinClose would never be reached.  So we need to add the Escape sequence to 1st close x360ce, and then yuzu.

Run, "C:\Users\Gerry\Desktop\X360CE\X360CE.exe",,Min

Esc::
{
	WinClose, ahk_exe X360CE.exe
	WinClose, ahk_exe Yuzu.exe
}

If X360CE needs to be fully loaded before yuzu, you may need to try something different.  As in, if this doesn't work, you'll need to go to plan "B". ;) 

Link to comment
Share on other sites

On 2/5/2022 at 3:44 AM, DeadVoivod said:

Sorry but I didn't find, but I would like to have a script to close DOSBox with Esc. DOSBox uses CTRL-F9 to close, I tried now many scripts, but none work. Or is there a better way to close DOSBox? 

Thanks. 

Not sure if you have tried these but they work here

Number 1

Esc::^F9

Number 2

Esc::
Winclose, ahk_exe DosBox.exe

Number 3

Longwinded - but remap the shutdown key inside Dosbox and then use that new mapper.map file inside your dosbox.conf file but if you are using a separate conf file for each game you might need to add it to each one - however if only using dosbox.conf for all game then this might be the easier way as not having to mess around with AHK's and just rebinding it in the actual programme

 

Disclaimer 

This is using Dosbox that comes packages with Launchbox in the third party folder and not any of the other versions/options

Link to comment
Share on other sites

Sorry to hear not working for you.

Are you running DosBox or anything else as admin or anything different?

I take it you have put it here - the script section in tools?

image.thumb.png.c06908fd5317e30147ae99d6e44292c7.png

I have attached conf and map files for a fresh Dosbox version with no other changes apart from making Esc exit the programme - might be worth making a copy of your current files and trying these - pathway is something like C:\Users\?????\AppData\Local\DOSBox - well it is for me might be different for you

Works when load just Dosbox or also a game as long as game conf file doesn't redirect to a different map file - fingers crossed it works for you

dosbox-0.74-3.conf mapper-0.74-3.map

Link to comment
Share on other sites

9 hours ago, JoeViking245 said:

 

 

I assume this in your Running Script section of the emulator.  Adding a couple of commas and "Min" should start x360ce minimized. 

Normally you could add the WinClose yuzu after the WinWait.  That won't work here because as soon as the emulator (yuzu) exits, this script is abandoned.  WinClose would never be reached.  So we need to add the Escape sequence to 1st close x360ce, and then yuzu.

Run, "C:\Users\Gerry\Desktop\X360CE\X360CE.exe",,Min

Esc::
{
	WinClose, ahk_exe X360CE.exe
	WinClose, ahk_exe Yuzu.exe
}

If X360CE needs to be fully loaded before yuzu, you may need to try something different.  As in, if this doesn't work, you'll need to go to plan "B". ;) 

Thank you Joeviking! Yes this is my running script, and I don’t believe x360ce needs to be loaded first, I will try this tonight. Thanks again!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Kiinkyfoxx said:

I take it you have put it here - the script section in tools?

Yes, it's exactly there where I put the script. 

I will try your configs tomorrow, thanks a lot. 

I imported ExoDOS and ExoWIN, so I just double click the game and it launches in DOSBox, I didn't fiddle around with anything when it comes to DOSBox. 

Link to comment
Share on other sites

Hi there, I was wondering if someone could kindly create a script for me to go with the Dolphin emulator.

I want to make it so that every time I launch Dolphin, it also launches DS4Windows. But I also want DS4Windows to close when I close Dolphin.

I use reWASD now for my controller profiles, but the problem is that only DS4Windows seems to have the option to let you map an Xinput controller with gyro controls. This is the only way I've found to get both motion controls and rumble with my PS5 controller when using Dolphin.

So I have to begrudgingly use DS4Windows for at least that one specific purpose. It would help me a ton if someone could help me pull this off.

Link to comment
Share on other sites

23 hours ago, JoeViking245 said:

 

 

I assume this in your Running Script section of the emulator.  Adding a couple of commas and "Min" should start x360ce minimized. 

Normally you could add the WinClose yuzu after the WinWait.  That won't work here because as soon as the emulator (yuzu) exits, this script is abandoned.  WinClose would never be reached.  So we need to add the Escape sequence to 1st close x360ce, and then yuzu.

Run, "C:\Users\Gerry\Desktop\X360CE\X360CE.exe",,Min

Esc::
{
	WinClose, ahk_exe X360CE.exe
	WinClose, ahk_exe Yuzu.exe
}

If X360CE needs to be fully loaded before yuzu, you may need to try something different.  As in, if this doesn't work, you'll need to go to plan "B". ;) 

It is opening x360ce in the background, but on esc, its causing x360ce to not respond.  Any ideas on that?

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