Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Hoping someone can help me with a Ahk Script please. I’m using Mouse Patcher in  PSCX2  I need MP to open when launching a game which I’ve got working with ‘run, (and then path to MP)’ I then need the inputs - press space bar, tab, space bar

This will turn off the cheats that are enabled and then I’d like MP to close when exiting the game which is the default pressing escape or my start and select on my controller. 

Hope someone could help me with getting this working 

 

Thanks a lot 

Edited by Johno1980
Link to comment
Share on other sites

7 hours ago, Johno1980 said:

Hoping someone can help me with a Ahk Script please. I’m using Mouse Patcher in  PSCX2  I need MP to open when launching a game which I’ve got working with ‘run, (and then path to MP)’ I then need the inputs - press space bar, tab, space bar

This will turn off the cheats that are enabled and then I’d like MP to close when exiting the game which is the default pressing escape or my start and select on my controller. 

Hope someone could help me with getting this working 

 

Thanks a lot 

This is my AHK for Mouse Patcher-it runs as an additional app before game loads, only use it on a few games so easy to add as an additional app to them

#SingleInstance, Force

run, Insert your path to MP\PcSx2MP.exe                ;path to exe goes here
WinWaitActive, ahk_exe PcSx2MP.exe    ;makes script wait for exe to open
SendInput {Space}            ;sends a Space
SendInput {Tab}                ;sends a Tab
SendInput {Space}            ;sends a Space
ExitApp

 

To close it try changing the shutdown part of the running script tab in emulator- I haven't put my full script up as it does some other bits you won't need

So it will look something like this

!!!!WARNING I don't have the original closing command for PCSX2 on mine and cannot remember it so I have used Process, Close as a place holder-This can cause issues with Emulators as isn't the ideal way to close it-so please replace that line with whatever your current and correct closing command is!!!!

$Esc::
{
WinClose, ahk_exe PcSx2MP.exe
Process, Close, {{{StartupEXE}}}                           ;I know we shouldn't use Process, Close and I am not suggesting it-I use a different command specific to mine so have used this as a place holder-please replace it with whatever the current command for closing down your version of PCSX2 is
}

Hopefully that works for you

Link to comment
Share on other sites

1 hour ago, Kiinkyfoxx said:

This is my AHK for Mouse Patcher-it runs as an additional app before game loads, only use it on a few games so easy to add as an additional app to them

#SingleInstance, Force

run, Insert your path to MP\PcSx2MP.exe                ;path to exe goes here
WinWaitActive, ahk_exe PcSx2MP.exe    ;makes script wait for exe to open
SendInput {Space}            ;sends a Space
SendInput {Tab}                ;sends a Tab
SendInput {Space}            ;sends a Space
ExitApp

 

To close it try changing the shutdown part of the running script tab in emulator- I haven't put my full script up as it does some other bits you won't need

So it will look something like this

!!!!WARNING I don't have the original closing command for PCSX2 on mine and cannot remember it so I have used Process, Close as a place holder-This can cause issues with Emulators as isn't the ideal way to close it-so please replace that line with whatever your current and correct closing command is!!!!

$Esc::
{
WinClose, ahk_exe PcSx2MP.exe
Process, Close, {{{StartupEXE}}}                           ;I know we shouldn't use Process, Close and I am not suggesting it-I use a different command specific to mine so have used this as a place holder-please replace it with whatever the current command for closing down your version of PCSX2 is
}

Hopefully that works for you

Thanks for the reply and have it launching now with the Game however the space and tab inputs don’t seem to work atm 

when I press start and select on my controller it exits the game and shuts down MP which is perfect. However when I press escape on my keyboard it only exits the game and leaves MP open. 
 

when I add $Esc:: into the shutdown 

esc works and shuts down both however start and select doesn’t work on my controller  then to exit lol 

 

so almost there just needs some tweaking lol and thanks again for the help

8A061EA3-1670-47D3-BC52-CF1393F76750.jpeg

07400872-FA64-4479-8F8C-2FDF415E8C4C.jpeg

Link to comment
Share on other sites

@Johno1980

You need the Winclose, ahk_exe PcSx2MP.exe part in both the tabs you have shown above-Sorry that was bad instructions on my part.

In running Autohotkey Tab as picture above add the

Winclose, ahk_exe PcSx2MP.exe

line so the bits in the { } look the same as the exit Tab

I don't open MP via that tab, as mentioned I add it as an additional apps to the games so that it starts up before the game. I think the way that you are doing it that MP maybe doesn't have focus when the keys are sent to it-if they are even sent-Try the two files below to see if it is working-basically download both and keep together, run the exe and it should then open MP and clear the two check boxes-If it does just keep the two files together and then add the exe as the additional app

If that doesn't open MP just check the ahk file that I copied your pathway correctly.

From memory there were only about 8 games that used the MP so not too many to add it to, unless it actually works on a lot more now?

If you want to do it the way you have set it up I imagine you will need to activate the window before sending the key strokes, but then it will show up above the game window, so you will then need to set the game window back to the top, which is why I just went the additional app route as that way it all happens hidden away and looks nicer.

Cheers

 

MP Launcher.ahk MP Launcher.exe

  • Like 1
Link to comment
Share on other sites

7 hours ago, STAINLESS said:

how can i use autohotkey scripts when i use bat files to launch the emulator?
i do not have an emulator associated with the system in launchbox

If you compile the AHK into an Exe you could start the Exe with the bat file before starting the emulator. 

If you don't compile the AHK then just copy the autohotkey.exe and rename to same as ahk file and start that exe in bat file. 

You can either make the AHK self closing or close it via the same bat file. 

Or if the system has numerous games on it that all use the same emulator, could you not set up a bat file that captures the variable of the rom pathway/name from Launchbox and loads that. Then you can set that bat file as the emulator, calling the emulator whatever you want, Eg System Name emulator. This would let you use all the emulator tabs and options. 

  • Like 1
Link to comment
Share on other sites

13 hours ago, Kiinkyfoxx said:

If you compile the AHK into an Exe you could start the Exe with the bat file before starting the emulator. 

 

actually this is what i thunked of when i was trying to get to sleep lol.
Thanks :)

Quote

Or if the system has numerous games on it that all use the same emulator, could you not set up a bat file that captures the variable of the rom pathway/name from Launchbox and loads that. Then you can set that bat file as the emulator, calling the emulator whatever you want, Eg System Name emulator. This would let you use all the emulator tabs and options. 

I like this idea, not sure it will work in this instance though, as its Cemu and the rom pathway/names are the reason i launch each game with its own bat files

Thanks again :)

Edited by STAINLESS
Link to comment
Share on other sites

8 hours ago, STAINLESS said:

actually this is what i thunked of when i was trying to get to sleep lol.
Thanks :)

I like this idea, not sure it will work in this instance though, as its Cemu and the rom pathway/names are the reason i launch each game with its own bat files

Thanks again :)

You dont need anything extra to launch games in cemu, what are you actually trying to accomplish?

Link to comment
Share on other sites

10 hours ago, neil9000 said:

You dont need anything extra to launch games in cemu, what are you actually trying to accomplish?

i have my own per game configs that i load with each game.

For instance, some work better for me in opengl, some in vulkun.

I have different control setups for different games, like super mario U to work in multiplayer, they just swap around with the bat files.

 

what im trying to accomplish is keeping the above options, and being able to close with back+select. the AHK .exe method should do it.

 

Edited by STAINLESS
Link to comment
Share on other sites

Hey all, I'm back with a new problem that I can't seem to get my head wrapped around. I want to add controller profile functionality to my rocketlauncher module for yuzu. I have reached out on that forum but they aren't helpful, they tell me to check out another module. I am trying to avoid ini read/write to maintain original script finctionality. To avoid redundancy, the link to my post can be found here.

I want to keep things simple. I want to have all my config files in a folder called Profiles within "yuzu/user/config" and each config be named after the game. When a game is set up in RL (which I have already added the functionality to the menus, quite simple actually, it's the module that I need help with), it would backup the original qt-config.ini file, grab the profile ini, rename it to qt-config.ini and pace it in the "yuzu/user/config" directory, then upon exiting the game, it would replace the original qt-config.ini. 

I think that possibly having an ini named default in the profiles directory would work, but it may be redundant...or backing up the original would be....I just want to keep it short, sweet and basic.  If someone would be so kind as to help me on this, I would greatly appreciate it. All credit will be given and I will happily share my finished product with anybody interested.

Link to comment
Share on other sites

@CtinD Are these custom game config ini files something that could be loaded from a command line parameter?  I have never used RL and have no idea what yuzu is, but if it were possible (bear with me here..)

Say we have the emulator myEmu.exe it takes the command line -yuzu and then the name of the rom mario.zip

myEmu.exe -yuzu mario.zip

And say this, by default, loads qt-config.ini.  Is there a command you can put in there to load a custom config file?  Say something like -config=?

myEmu.exe -yuzu -config=mario.qt-config.ini mario.zip

And if so, could you then put in a custom command line for each game, replacing both instances of "mario" with the name of the game?

If "Yes", then there's a quick, easy solution.  (easier than editing each and every game)

If "Yes, but I use an AHK script, and the games name would have to change in the script", then there's a relatively easy solution.

If "No! You have no idea what you're talking about.", then never mind. I tried.   ?

Link to comment
Share on other sites

2 hours ago, JoeViking245 said:

@CtinD Are these custom game config ini files something that could be loaded from a command line parameter?  I have never used RL and have no idea what yuzu is, but if it were possible (bear with me here..)

Say we have the emulator myEmu.exe it takes the command line -yuzu and then the name of the rom mario.zip


myEmu.exe -yuzu mario.zip

And say this, by default, loads qt-config.ini.  Is there a command you can put in there to load a custom config file?  Say something like -config=?


myEmu.exe -yuzu -config=mario.qt-config.ini mario.zip

And if so, could you then put in a custom command line for each game, replacing both instances of "mario" with the name of the game?

If "Yes", then there's a quick, easy solution.  (easier than editing each and every game)

If "Yes, but I use an AHK script, and the games name would have to change in the script", then there's a relatively easy solution.

If "No! You have no idea what you're talking about.", then never mind. I tried.   ?

Lol, I knew you would be the one to chime in on this, I didn't want to burden you with a private message. So, I have yuzu functioning as is. It loads games just fine in rocket launcher as well. The emu doesn't have per game configs baked into it though, that's why I am trying to achieve this through AHK.

RocketLauncher loads games through AHK scripts and is very aesthetically appealing while doing what it does. Using it and setting it up is not for the faint of heart or easily discouraged.However, I have made some basic modules (ahk scripts) in the past and is how I got my feet wet in AHK. Anyhow, dolhpin emu doesn't have a pergame controller config system that you can setup without fiddling with the controls menu, so they baked function that into the module, same with per game memory cards in PCSX2. The issue is, it does ini read/writes and if I start doing that, I will break the functionality of Yuzu's script. So I am wanting to do it the quick and dirty way, which is just copying and renaming and at the end, reverting back to the default config. Doing it this way would allow for the functionality that already in the Yuzu module to function as intended while adding this functionality, which others seem to be clamoring for.

Would you mind if I sent you a message with the scripts to see what I am trying to acheive?

Edited by CtinD
added more info
Link to comment
Share on other sites

If it's a matter of inserting something into an existing script to backup/copy/restore the ini file, i think you're looking for something along these lines

currGame := %1%	       ;%1% or however you get the games name to this script
defConfig :=    "D:\Emulators\Yuzu\Config\qt-config.ini"
defBackup :=    "D:\Emulators\Yuzu\Config\qt-config.bak"
gameConfig :=   "D:\Emulators\Yuzu\Config\Games\%currGame%.qt-config.ini"

if FileExists(%gameConfig%)
{
   FileMove, %defConfig%, %defBackup%, 1		;rename to .bak, overwrite if it exists
   FileCopy, %gameConfig%, %defConfig%, 1		;copy in the game.ini
}

and then after exiting the game

FileCopy, %defConfig%,%gameConfig%, 1     ;copy the game.ini back (because it changes during gameplay???)
FileMove, %defBackup%, %defConfig%, 1     ;restore original config file

Or compile those to run Before game starts, and After game exits. respectively.

Link to comment
Share on other sites

18 hours ago, JoeViking245 said:

If it's a matter of inserting something into an existing script to backup/copy/restore the ini file, i think you're looking for something along these lines


currGame := %1%	       ;%1% or however you get the games name to this script
defConfig :=    "D:\Emulators\Yuzu\Config\qt-config.ini"
defBackup :=    "D:\Emulators\Yuzu\Config\qt-config.bak"
gameConfig :=   "D:\Emulators\Yuzu\Config\Games\%currGame%.qt-config.ini"

if FileExists(%gameConfig%)
{
   FileMove, %defConfig%, %defBackup%, 1		;rename to .bak, overwrite if it exists
   FileCopy, %gameConfig%, %defConfig%, 1		;copy in the game.ini
}

and then after exiting the game


FileCopy, %defConfig%,%gameConfig%, 1     ;copy the game.ini back (because it changes during gameplay???)
FileMove, %defBackup%, %defConfig%, 1     ;restore original config file

Or compile those to run Before game starts, and After game exits. respectively.

WOW! THANK YOU SO MUCH!  This is almost exactly what I needed. From the looks of it, it is looking like it's moving the config rather than copying it. Am I reading this correctly? Now...the only thing left, is renaming the profiles...or am I just not seeing that? I haven't had my rockstar this morning yet. SO I am not fully awake. That's my story and I am sticking to it. 

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