Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Quote

Thanks so much for this info! I will update my Flycast and M2 scripts  :)

9 minutes ago, Retro808 said:

It been long recommended to no longer use Process, Close as it is a hard close script. The script below if better to use.

I know by default LB puts the Process, Close script in a few emulators and I have asked Jason if we can update LB with the better code.


; This section closes emulator when pressing Escape
$Esc::
{
	WinClose, ahk_exe {{{StartupEXE}}}
}

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi!

I want to implement an autohotkey script that open/closes BetterJoy when running/closing a game on Dolphin.

I use BetterJoy for Dolphin, because it helps me playing Wii games with motion control of my joycons.
But it doesn't work well with other emulators, so I need it to close everytime I close Dolphin, and open again everytime I open Dolphin again.

I've no knowledge of autohotkey scripts. Hope someone can help me.

Link to comment
Share on other sites

@The_Keeper86  Sort answer: no.

Medium answer (which is actually a question): is there a command of sorts (or program) you can run that will actually "turn off" a controller?

Longer answer: assuming the answer to my question is yes, the easiest way to do this is to create a batch file that starts BigBox, waits for it (BB) to close and then runs the "program" to turn off the PS4 controller.

@echo off
d:
cd "D:\LaunchBox\Core"
start /w "" BigBox.exe

cd "D:\PS4_Controller_Folder"
start "" "Turn_Off_PS4_Controller_Program.exe"

If you're feeling really ambitious, you could create a plugin and use the API call "BigBoxShutdownBeginning" and then run your "turn off" program there. ;) 

Link to comment
Share on other sites

@The_Keeper86  So the "command" is press the  PS & ∆  buttons at the same time?  Hmmm......   well then.... I have no idea. 

I can tell you how to say, open NotePad if the  PS & ∆  buttons are pressed.    [Detect an XInput Button press]

But I have idea how to... if Notepad is opened, 'press the  PS & ∆  buttons'.     [Send an XInput Button press]

Obviously an oddball example, but detecting and sending Xinput stuff are two different animals.

Link to comment
Share on other sites

@JoeViking245 Yeah, as long as Steam is opened it'll turn off the controller. I use Kodi to launch Lb into BB and you can set a before launching and exiting command/script. I was thinking of launching whatever app or command  I could use to turn off the controller after exiting BB. But isn't a big deal to press the button combinations. Just figured it'd be more convenient ha ha. I appreciate you trying to help me though. Maybe someone else might know? I know it's a weird request.

  • Like 1
Link to comment
Share on other sites

Alright y'all, I'm beating my head against a wall with this and it's probably something simple, but I cannot get this to work. The section in green works fine so long as the section in red isn't present. If the section in red is there none of the section in green works. If I put the red section in second it doesn't work. I've tried placing the WinWaitClose through ExitApp portions within each sub function underneath the hotkeys but if I do that it runs through the entire sequence as soon as I press the hotkey despite the fact that Retroarch hasn't closed (it closes CDisplay and itself at that point). I've tried using if/else statements and didn't have any more luck with that either.

All I need is a hotkey combo that flips between two windows (Retroarch and CdisplayEx in this case) and that part works fine, but I also need it to watch and close CdisplayEx and itself once Retroarch closes and at this point I'm getting one or the other but not both no matter what I try.

SetTitleMatchMode, 2
WinWait, RetroArch VICE
WinWaitClose
Process, Close, Cdisplayex.exe
ExitApp

Hotkey, ~NumpadSub & NumpadEnter, Function1
Return

Function1:
SetTitleMatchMode, 2
WinActivate, Cdisplayex
  Hotkey, ~NumpadSub & NumpadEnter, Function2
Return

Function2:
SetTitleMatchMode, 2
WinActivate, RetroArch VICE
  Hotkey, ~NumpadSub & NumpadEnter, Function1
Return

 

Link to comment
Share on other sites

Alright, think I figured it out. This seems to be working.

Hotkey, ~NumpadSub & NumpadEnter, Function1
Process, WaitClose, Retroarch.exe
Process, Close, Cdisplayex.exe
ExitApp
Return

Function1:
SetTitleMatchMode, 2
WinActivate, Cdisplayex
  Hotkey, ~NumpadSub & NumpadEnter, Function2
Return

Function2:
SetTitleMatchMode, 2
WinActivate, RetroArch VICE
  Hotkey, ~NumpadSub & NumpadEnter, Function1
Return

  • Like 1
Link to comment
Share on other sites

hi,

i need a script to exit n64 games for my N64 controller. he should have a different exit key as my regular controller in launchbox.

tryed this, but didn't work:

Joy7::
If GetKeyState("Joy8")
{
    Process, Close, {{{StartupEXE}}}
}

so usually i want to hold the start button (Joy7) and press up on the digital pad. in this sctipt above i hold the start button and pres the z trigger. but it generally does not work...any tips? (im using Project64 as Emulator)

Edited by FR0NZ
Link to comment
Share on other sites

Try swapping Joy7 and Joy8.  Also I think you need to tell it which controller you're using [by adding the "1" at top].

1Joy8::
If GetKeyState("Joy7")
{
    WinClose, ahk_exe {{{StartupEXE}}}
}

Here, you need to press (and hold) Joy7 first, and then press Joy8.  

Also, the "WinClose" is a better exit command to use.  Just sayin'. ;) 

Link to comment
Share on other sites

35 minutes ago, JoeViking245 said:

Try swapping Joy7 and Joy8.  Also I think you need to tell it which controller you're using [by adding the "1" at top].


1Joy8::
If GetKeyState("Joy7")
{
    WinClose, ahk_exe {{{StartupEXE}}}
}

Here, you need to press (and hold) Joy7 first, and then press Joy8.  

Also, the "WinClose" is a better exit command to use.  Just sayin'. ;) 

dont work.. :/

Link to comment
Share on other sites

16 hours ago, JoeViking245 said:

Do you have more than one controller? Are you using controller #1?  Are you pressing and holding button 7 before pressing button 8?  Are you sure those are the correct button numbers for your controller? 

tryed it with my regular controller and it works....

looked the buttons in launchbox settings for my n64 controller...start = button 10 and Z = button 8.

when i connect my n64 controller and disconnect all others, the script must be work...:

Joy8::
If GetKeyState("Joy10")
{
    Process, Close, {{{StartupEXE}}}
}

but it wont work..maybe ahk handle the buttons with other numbers for my n64 controller?

 

//EDIT:

Finally it works :)

2Joy8::
If GetKeyState("2Joy10")
{
    Process, Close, {{{StartupEXE}}}
}

 

Edited by FR0NZ
Link to comment
Share on other sites

36 minutes ago, FR0NZ said:

maybe ahk handle the buttons with other numbers

No. It'll use the same numbers.  If you don't mind doing a little experimenting/troubleshooting... with your N64 controller plugged in and no other controllers, try this

Joy10::
KeyWait, Joy10, T1
if (ErrorLevel)
Process, Close, {{{StartupEXE}}}

Launch a game and once it's loaded, press and hold your Start button for 2 to 3 seconds.  If all goes well, it will close your emulator.

And if not, it's probably a problem with the joy #.  Read more here: 

 

 

Link to comment
Share on other sites

On 11/16/2020 at 3:08 PM, JoeViking245 said:

No. It'll use the same numbers.  If you don't mind doing a little experimenting/troubleshooting... with your N64 controller plugged in and no other controllers, try this


Joy10::
KeyWait, Joy10, T1
if (ErrorLevel)
Process, Close, {{{StartupEXE}}}

Launch a game and once it's loaded, press and hold your Start button for 2 to 3 seconds.  If all goes well, it will close your emulator.

And if not, it's probably a problem with the joy #.  Read more here: 

 

 

it works now.

first i have looked which joystick driver my n64 controller use with the joystick test script.
its on the ahk page: https://www.autohotkey.com/docs/scripts/index.htm#JoystickTest

they displayed joystick #2

finally my code:

2Joy8::
If GetKeyState("2Joy10")
{
    Process, Close, {{{StartupEXE}}}
}

 

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

Hi could somebody help me with getting a close on Esc script to work with Kronos 2.1.3 Standalone, its set up to close on Ctrl + Q and ive been trying and failing to guess at the answer for a little while, ive tried the "Standard" close on Esc Script and seen some other scripts in this thread that looked close to what i needed and have tried to use / adapt them for what i need, with no luck. Could anybody provide me with the answer please?

Link to comment
Share on other sites

Hi all

Is it possible to write a script I can import into LaunchBox that does the following:

 

1) Mounts a cd image

2) Runs an *.exe from a different directory

3) Monitors to check if a process is running, and if it is, then ignore, if not, then issue a command (to unmount the cd image) & exit AHS.

 

I've had various degrees of success, but nothing works completely. I can point LaunchBox to the *.nrg image which mounts it in Daemon tools, I can then add an additional app to launch the game's exe from another directory (autoplay on disc doesn't work, so exe needs to be launched separately)....what I cannot get to happen though, is unmounting the cd image from Daemon tools if I exit the game. I've tried various methods of scripts, but nothing works.

 

The game is Civilization II Gold....so the disc needs to be mounted for the music to work, and then the exe needs to be launched from the installation directory. Game plays fine, but because in LB the "main program" is the disc image being mounted, the additional app feature "automatically launch after..." isn't hugely helpful. I'd appreciate any help at all

Link to comment
Share on other sites

4 hours ago, JoeViking245 said:

What exactly have you tried?

Have you tried this:


$Esc::
Send, ^q

 

Hi JoeViking, thanks for the reply. Yeah i had tried that one (i think it was posted in this thread earlier saying it worked for Citra and that it was a Ctrl + Q close command, so i was chuffed when i came across it... but it doesnt work for Kronos stand alone. :/ i have no idea why?) I have retried it as you have posted (incase i had made an error previously) in both the Running and Exit Autoscript boxes, still no luck

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