Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

Hi guys.. don't know enough about setting up ahk to do what I need in regards to Xbox trigger buttons.  I want to exit cemu with the right trigger.  On controller settings, r trigger is identified as JoyZ.  How do I write this?  

What I've tried:

$JoyZ::

{

          Process, Close, {{{StartupEXE}}}

}

 

And 

Joy1Z::Send {ESC}  ;

$ESC::

 

{

 

          Process, Close, {{{StartupEXE}}}

 

}

 

Nothing's working.. also tried variations of JoyZ< and JoyZ>.. 

 

Help?

Link to comment
Share on other sites

2 hours ago, Billybong said:

r trigger is identified as JoyZ.  How do I write this?

Try  $1JoyZ  or  1JoyZ 

The "1" in front of "Joy" tells it 'controller #1'.  The [single] number (or letter) after "Joy" tells it which 'button' to watch for.  I haven't tested triggers. So not sure if/how that'll work as they start at 0 [zero] and go +/- between pressing and releasing (vs. a buttons on/off).

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

Try  $1JoyZ  or  1JoyZ 

The "1" in front of "Joy" tells it 'controller #1'.  The [single] number (or letter) after "Joy" tells it which 'button' to watch for.  I haven't tested triggers. So not sure if/how that'll work as they start at 0 [zero] and go +/- between pressing and releasing (vs. a buttons on/off).

Will give this a try.  Wouldn't be so bad if escape wasn't tied to r trigger, but coming off an ipac2 in gamepad mode, unfortunately switch 7/8 are left and right triggers.  

Link to comment
Share on other sites

55 minutes ago, Billybong said:

Will give this a try.  Wouldn't be so bad if escape wasn't tied to r trigger, but coming off an ipac2 in gamepad mode, unfortunately switch 7/8 are left and right triggers.  

That kind of doesn't make sense.  You wanted to exit Cemu with the right trigger (of an Xbox controller) . [hence the script]  Which as I think about it now seems odd because wouldn't you be using the right trigger during game play?  I personally haven't messed with it that much to know.

Then now you're saying Escape is tied to the right trigger.  Where does the I-Pac2 fit into all this?  Do you have Cemu configured for your cab buttons (I'm assuming that what's connected to the I-Pac2) and for your Xbox controller?  I'm not trying to sound an arse. Just trying to get an overall idea of what you're dealing with.

Cemu doesn't require any special scripts to exit back to LaunchBox/BigBox.  And you can change the Exit Game button(s) Mapping (in LaunchBox/BigBox) to anything you want.  It doesn't have to be the default Button7 + Button8 combo.   Personally, I use the Right Shoulder + Back button combo because I'm pretty sure I wouldn't accidentally hit those simultaneously in the middle of a game. lol  

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

That kind of doesn't make sense.  You wanted to exit Cemu with the right trigger (of an Xbox controller) . [hence the script]  Which as I think about it now seems odd because wouldn't you be using the right trigger during game play?  I personally haven't messed with it that much to know.

Then now you're saying Escape is tied to the right trigger.  Where does the I-Pac2 fit into all this?  Do you have Cemu configured for your cab buttons (I'm assuming that what's connected to the I-Pac2) and for your Xbox controller?  I'm not trying to sound an arse. Just trying to get an overall idea of what you're dealing with.

Cemu doesn't require any special scripts to exit back to LaunchBox/BigBox.  And you can change the Exit Game button(s) Mapping (in LaunchBox/BigBox) to anything you want.  It doesn't have to be the default Button7 + Button8 combo.   Personally, I use the Right Shoulder + Back button combo because I'm pretty sure I wouldn't accidentally hit those simultaneously in the middle of a game. lol  

So it's 2fold.  I am using an ipac2 in a fighter cab with the ipac in gamepad (x360) mode.  Running Cemu specifically for 1 game.  So current control panel is set for 6 buttons each for p1 and p2 (a,b,x,y,lb,rb).  Switch 7 and 8 on p1 side (left and right triggers in gamepad mode) I use as "exit" and "tab".  There's no issues in Mame or RetroArch reassigning exit and tab to these buttons.  As for Cemu though, I need to use AHK to exit out of the emulator, but I want it to exit with the right trigger. 

Using the exit script, I can exit the emulator using ESC button on a keyboard, but I want to assign the right trigger to send escape.  

Unless Cemu will allow me to assign an  exit emulator button, I need a script that will allow me to exit the emulator with the rTrigger. 

So in all, I need a script that will allow me to send ESC when the right trigger is pressed and then escape exits the emulator.

Sorry if that comes off confusing.. 

 

Edited by Billybong
Link to comment
Share on other sites

3 hours ago, Billybong said:

ipac in gamepad (x360) mode.

I think it's called "xinput" mode that your I-Pac 2 is in.  Maybe they call it both. My I-Pac Mini doesn't have that feature, so I can't help [directly].  Hopefully someone who's familiar with that can chime in.

This might be a little hokey [Yes. hokey. not 'hotkey'. lol], but this worked with my Xbox 360 controller's right trigger.  So it "should" work on the I-Pac when in xinput mode. (I think)

#persistent
SetTimer, WatchAxis, 5
return

WatchAxis:
GetKeyState, JoyZ, JoyZ  

if JoyZ < 45
{
  WinClose, ahk_exe {{{StartupEXE}}}
  sleep 500
}

(script adapted from https://www.autohotkey.com/boards/viewtopic.php?t=23189)

You can put this in your Running AutoHotkey Script tab for your Cemu emulator.  And with fingers crossed, it'll do what you want.

Oh ya, "WinClose" is a preferred method over "ProcessClose" in AHK.

Link to comment
Share on other sites

2 hours ago, JoeViking245 said:

I think it's called "xinput" mode that your I-Pac 2 is in.  Maybe they call it both. My I-Pac Mini doesn't have that feature, so I can't help [directly].  Hopefully someone who's familiar with that can chime in.

This might be a little hokey [Yes. hokey. not 'hotkey'. lol], but this worked with my Xbox 360 controller's right trigger.  So it "should" work on the I-Pac when in xinput mode. (I think)

#persistent
SetTimer, WatchAxis, 5
return

WatchAxis:
GetKeyState, JoyZ, JoyZ  

if JoyZ < 45
{
  WinClose, ahk_exe {{{StartupEXE}}}
  sleep 500
}

(script adapted from https://www.autohotkey.com/boards/viewtopic.php?t=23189)

You can put this in your Running AutoHotkey Script tab for your Cemu emulator.  And with fingers crossed, it'll do what you want.

Oh ya, "WinClose" is a preferred method over "ProcessClose" in AHK.

Thank you so much... It worked!  Really appreciate the help.  Now my cabs perfect..

  • Game On 1
Link to comment
Share on other sites

Hi, 

I am after 2 scripts if anyone can help. 

One that opens x360ce and then minimises it. The other that closes x360ce. I will save these scripts in the settings platform I have created with the two scripts visible here and for me to select in BB. 

I know I will need to enter my own path to where x360ce is saved on my pc, but do not know where to start with the coding/what to write in the script. 

TIA

Link to comment
Share on other sites

17 hours ago, 00aedwards said:

the two scripts visible here and for me to select in BB. 

To be clear, You're wanting to add 2 "games" (which are actually the 2 'scripts' you're asking for) to their own Platform (we'll call it "Extras").  Then in BigBox, you open the Platform "Extras" and launch the "game" [we'll call it] "Start x360ce".  [I imagine then] at this point you'll go play some games the require x360ce to be running. Then when wanting to play a game that doesn't require it, you'll got "Extras" and launch "Shutdown x360ce".

There's potentially unavoidable issues doing it that way in BB. (will explain more once clarified)

If you need x360ce for all games in all platforms, you're best off creating a batch file that will start x360ce, then run BigBox, and then when you exit BB, shutdown x360ce.  That would look something like:

Start /min "D:\Games\Extras\x360ce\x360ce.exe"
cd "D:\LaunchBox\core"
start /w "" BigBox.exe
c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM x360ce.exe

Lines explained:

  1.   Start x360ce minimized ("/min")
  2.   You MUST start BigBox.exe from your  ../LaunchBox/Core  folder! Not BigBox.exe that in LB's root folder.
  3.   Start BigBox.  "/w" will pause the batch file ("wait") until BigBox exits.
  4.   Shutdown x360ce.  It's my understanding x360ce is a fickle thing to close, so a little "brute force" is necessary

If you only need x360ce for certain emulators (and not all) or for just certain games (and not all the games that use 'that emulator', we'll need a different approach.

And if I totally misunderstood... let me know.

Link to comment
Share on other sites

Hi Joe, 

Thanks for your reply. Yes you are spot on. Two AHK files. Listed as games in an settings platform. 

One to open x360ce then minimises it so it runs in the background. 

Then another to close x360ce. 

The reason for this is because my arcade buttons are now mapped as an x360 controller and assigned P1 and P2. There will be certain games that I will use the xbox360 controller, but the xbox controller is assigned P3 and I want the flexibility of being able to choose. 

I have this working in the most part already. I have created a link to x360ce as a game in a settings folder which I can now access and run in big box. Although what this does is bring up the application onto my screen. I then use a mouse to close it when I want to switch to the xbox controller, If I'm going from using an Xbox controller to wanting to use the arcade stick again I run the program, which brings up the x360ce window and just minimise. 

By closing the x360ce application I can assign player 1 to my xbox controller. The issue is being able to reassign controller numbers as the arcade sticks are p1 and p2 as default. 

 

Hope that made sense and I've not confused you more! 

 

 

Link to comment
Share on other sites

13 minutes ago, 00aedwards said:

Hope that made sense and I've not confused you more! 

For having been spot on before and with more details here, I think I'm good now. lol

I think you'll be better off just using a batch file (vs an AHK script).  You get the same outcome either way.  Plus it's easier to describe. ;) 

Create 2 new text files.  "Start x360ce.txt" and "Shutdown x360ce.txt".  Or name them what ever you want.

Inside "Start x360ce.txt", put

Start /min "D:\Games\Extras\x360ce\x360ce.exe"

Inside "Shutdown x360ce.txt", put

c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM x360ce.exe

Save and close both files.  In Windows Explorer, rename them to have the file extension ".bat"  i.e. "Start x360ce.bat".  

If  you can't see the file extensions...

image.png.6d2b42d1ed5491af73e76216ff29373d.png

Click the "View" tab and check "File name extensions"

image.thumb.png.649825103746f2a97a81158b5e7008af.png

When all's good, they should look like:

image.png.9cc87f1c50a05e205129abe59c5eb845.png

Add these to BigBox, and play games.:D

Link to comment
Share on other sites

17 minutes ago, 00aedwards said:

doesn't minimise the window after opening. 

Plan "B"  (actually should have done this in the 1st place.  Doh! lol)  Open Windows Explorer and navigate to where your x360ce.exe file is located.  Right click that file and select "Create Shortcut".  Now right click on this new 'file' ("x360ce.exe - Shortcut") and select "Properties".  On the Shortcut tab, next to "Run", click and select "Minimized".

image.png.d9b631977b4deca6b42f17b9116d8361.png

Click OK.  With x360ce NOT running, double the the shortcut.  It should now start minimized.  Have BB point to that shortcut instead of the "Start..." batch file.  Delete the batch file.

30 minutes ago, 00aedwards said:

The second one. I'm not sure it's doing anything. It's not closing x360ce down.

Double click the shortcut (in Windows Explorer, not in LB/BB) that you just created to start x360ce.  Now double click 'The second one' ("Shutdown...").  Is x360ce still running?  If it is still running, bring up the x360ce window so it's not minimized, Press ALT+Tab to get back to Windows Explorer and double click 'The second one' again.  Is x360ce still [still] running?  Or did it close this time?  If it still doesn't close it, that brings us to your next question...

42 minutes ago, 00aedwards said:

Have I typed something wrong. 

I can't tell you.  It's not that I won't.  It's just that I can't.  How about you tell me. ;)   Or you can share a screen capture of what's actually inside the batch file you created.  (right click the batch file and select Edit).

Link to comment
Share on other sites

1 hour ago, 00aedwards said:

Just created the short cut and changed the properties to minimised. It hides the black box which hosts the contents of the file ie the script you gave me, but not the x360ce application. That's still showing. 

When double clicking the shortcut, there won't be any 'black box' ("Windows command-window") to hide.  You made a shortcut to the original exe file. Right? Not a shortcut to the batch file?  [side note: the batch will have the "black box". But the shortcut won't]

"navigate to where your x360ce.exe file is located.  Right click that file"

Your "Shutdown..." batch file...  The last part is incorrect.  You have "x360.ce".  That should be "x360ce.exe". 

c:\windows\system32\cmd.exe /c c:\windows\system32\TASKKILL.exe /F /IM x360ce.exe

 

Link to comment
Share on other sites

  • 1 month later...

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