Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

14 hours ago, pafftis said:

I'm new. I want to make it possible to close the ps3. RPCS3 emulator from the joystick.
I made a script. I wrote it down: Manager -> platform -> Rpcs3(edit) -> Exit script.
In the joystick settings, I programmed the keyboard shortcut to exit the game. And so I'm going to exit this particular emulator with this script?

Under ToolsManageEmulatorsRPCS3Edit, you want to put your script in the Running Script section.

(It can be a little confusing) The Exit Script section is ONLY for when you select Exit from within the Pause Menu.

Link to comment
Share on other sites

12 hours ago, pafftis said:

How do I link pressing the left and right sticks to the esc button?

You'll need to press (and hold) the Left stick button 1st, then press the Right stick button.  (Right then Left won't work)

1Joy10::
   If GetKeyState("Joy9")
   {
      SendLevel, 1    
      Send, {Esc}
   }

 

Edited by JoeViking245
Fixed script (thanks skizzosjt for catching that)
Link to comment
Share on other sites

I just came to a eureka moment. I've been going nuts over why it seems everyone but me can use xinput controllers as a hotkey WITHOUT using the xinput library (small exception is any xinput controller can use the Guide button as a hotkey without use of xinput library, it must be called using vk07 as the hotkey). I just realized it seems to keep putting my controllers as higher numbers in the "XJoyY" iteration, with X being joystick (controller) number and Y being the specific button. For ex, I have a single Xbox 360 controller plugged into my PC just now,  no other controllers are plugged in and I've done restarts too, and it comes up as controller #3 in AHK's controller test script. https://www.autohotkey.com/docs/v1/scripts/index.htm#ControllerTest so I need to use 3Joy1 if I wanted to have the A button trigger something as an example.

I never noticed that little number in the text at top of the script. Just today I realize it's referring to the enumeration order of the controller! Img for reference.

image.png.b88db96ff1dc60a2c31fe70db19c0291.png

Also SUPER important part which I already knew of and THOUGHT was my main issue is this ONLY WORKS WITH AN XBOX 360 CONTROLLER. I normally use a wired Xbox One controller or wireless Xbox Series X controller when playing games. USING Joy1 or 1Joy1 TYPE HOTKEYS WITH XINPUT CONTROLLERS NEWER THAN XBOX 360 WILL NOT WORK. (unless one of the scripts windows is the active window to detect said inputs, but that makes any script useless in any real-world use case scenario). I just never understood why I couldn't get it to work even with my Xbox 360 controllers. Why I struggled with that is because I totally spaced out on the enumeration order until today, had I paid attention to that I wouldn't have been banging my head on the wall wondering why I cannot get xinput controller hotkeys to work on a Xbox 360 controller. I already understood why it doesn't work on my newer controllers, but I felt like I was missing something stupid simple for Xbox 360 controllers, and I obviously did miss something stupid simple lol

 This is why if you have a Xbox One or Xbox Series X style controller you cannot call a hotkey with JoyY or XJoyY (X being controller number and Y being specific button) and instead need to resort to using the xinput library. If you don't put a number prior to Joy it implies it's the first controller, ie JoyY using previous examples above

https://www.autohotkey.com/docs/v1/misc/RemapController.htm

image.thumb.png.5d3e4338c4709d14949cc8c409a3e36b.png

 

I think I know why it enumerates at # 3 now too. Under Bluetooth settings I can see a Xbox One wireless controller is still in the list, and it's #1 when used in AHK scripts. It just say it's "paired" in the device list rather than connected which makes sense, I haven't used that controller on this workstation PC for a long time I must have just left it in device list should I ever want to use it again. That way I wouldn't need to put it through another setup. I know that only takes like 30 secs but that was my thought process for leaving it - this obviously bit me in the rear though lol because I never thought to try 2Joy1 and only ever tried Joy1 or 1Joy1 (DOH!) My wired Xbox One controller (which is what I use when I do play games on this workstation PC) comes up at controller #2 and is also in the list. I just today plugged in the Xbox 360 wired controller, it was first time I plugged that in in a long time and wasn't in the device list so needed to be setup. So it goes to next available number, that being #3. Light bulb goes off at this point 💡 - Img for reference

image.thumb.png.254fc7bb722d4449b08bc663e7cafbdd.png

So I reckon people who never had an issue with using xinput buttons as a hotkey are using Xbox 360 controllers and they do not have multiple controllers in their device list. If you have multiple controllers in there, you need to be aware of what the controller number is according to AHK. You can try entering the next higher number until you find it or better yet, use their test script to know exactly what # it is.



I've been making use of the xinput library for my newer controllers. Which JoeViking did a great job helping me learn about a while back! If you scan back through this thread you should find those posts...somewhere in this enormous thread

 

Might be an error in that script btw. I think it needs braces or it's going to send esc when the first button is pushed without waiting for the 2nd button.

1Joy10::
   If GetKeyState("Joy9") {
   SendLevel, 1    
   Send, {Esc}
}
  • Thanks 1
Link to comment
Share on other sites

Hi,

I've just setup rpcs3, works great, in the running script i have -

$Esc::
Send, !{F4}

had to use this as the normal way -

$Esc::
{
WinClose, ahk_exe rpcs3.exe
}

Would sometimes show the slightly minimised rpcs3 window for a second or two then close, not sure if it's a problem with the latest nightly build (RPCS3 Version: 0.0.30-15947-17aeefe1 Alpha | master).

So using the f4 script it closes perfectly with the esc key but when i try using the Xbox one controller ( back and select - buttons 7 & 8 - pressed together) like i do with all the other emulators i've setup, it still shows the window, is there a way to alter the script to use controller buttons just for rpcs3 ?

Thanks in advance of any helpful replies :)

Cheers

-neo-

 

Edited by -neo-
Link to comment
Share on other sites

34 minutes ago, -neo- said:

is there a way to alter the script to use controller buttons just for rpcs3 ?

The 'formula' for the answer to your question is quite literally right above your post. ;) 

 

Here, you'll need to press (and hold) Button 7 before pressing Button 8.  

1Joy8::
   If GetKeyState("Joy7") {
     Send, !{F4}
}

You can replace the 3rd line with WinClose, ahk_exe rpcs3.exe, as necessary.

To make it "just for rpcs3", place it in the Running Script section (as you had previously done).

You can add it below (or above. doesn't matter) your existing Escape sequence to give you 'options'.  i.e. Use the keyboard OR the controller. 

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

The 'formula' for the answer to your question is quite literally right above your post. ;) 

 

Here, you'll need to press (and hold) Button 7 before pressing Button 8.  

1Joy8::
   If GetKeyState("Joy7") {
     Send, !{F4}
}

You can replace the 3rd line with WinClose, ahk_exe rpcs3.exe, as necessary.

To make it "just for rpcs3", place it in the Running Script section (as you had previously done).

You can add it below (or above. doesn't matter) your existing Escape sequence to give you 'options'.  i.e. Use the keyboard OR the controller. 

D'oh, must be blind in my old age 🤣  thanks for the quick reply, i'll give it a whirl :)

Link to comment
Share on other sites

2 hours ago, JoeViking245 said:

The 'formula' for the answer to your question is quite literally right above your post. ;) 

 

Here, you'll need to press (and hold) Button 7 before pressing Button 8.  

1Joy8::
   If GetKeyState("Joy7") {
     Send, !{F4}
}

You can replace the 3rd line with WinClose, ahk_exe rpcs3.exe, as necessary.

To make it "just for rpcs3", place it in the Running Script section (as you had previously done).

You can add it below (or above. doesn't matter) your existing Escape sequence to give you 'options'.  i.e. Use the keyboard OR the controller. 

D'oh, must be blind in my old age 🤣  thanks for the quick reply, i'll give it a whirl :)

 

**edit**

Just tried it and it still shows the window on closing so i changed to these buttons and nothing happens at all, it's the only controller i have plugged in at the moment -

1Joy6::
   If GetKeyState("Joy5") {
     Send, !{F4}
}

Any suggestions ?

Edited by -neo-
Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

Be sure you're pressing (and hold) the Left-Button (Joy5) BEFORE pressing the Right-Button (Joy6).

Sadly i've just done as you've instructed and it still does nothing, can anyone else try it and see if works for them, maybe there's a conflict my end 🫣

Link to comment
Share on other sites

I learned some more today about controller enumeration numbers. the device list, and the control panel in Windows means literally nothing for AHK detecting/enumerating controllers. the way things looked in my last post sure made it seem like that, but as I tested the theory, it was proven false.

I removed all three existing controllers from my device list. restarted my PC twice. plugged in my wired controller that was previously coming up as #2 and......it's still #2 per AHK scripts! even weirder is I never bothered to check control panel until today and there were even more "previous" controllers in there.....I don't actually own 7 controllers lmao but there were a bunch of greyed out instances of the same controller in there. I went down a rabbit hole of removing all these instances and even doing that didn't change stuff. this same controller, the only one in the device list, the only one in the control panel, the only one plugged into the PC, is still detected as "2Joy" per Windows and therefore AHK.

did some forum searching and found this. seems AHK does not forget these assignments due to it's actually how Windows assigns/remembers them. unlike xinput which works more like how us normal humans think. ie if controller "A" is #1 and controller "B" is #2.....if both are unplugged and then "B" is plugged back in it comes back instead as #1. per Windows and therefore AHK it doesn't work like that, it always remembers controller "B" is going to be controller #2 and it will be controller #2 even if it's the only controller plugged into your system and you have no other controllers in device list or control panel

https://www.autohotkey.com/board/topic/91621-ahk-detects-ghost-joystick-controllers/

 

 

On 1/13/2024 at 11:46 AM, -neo- said:

Sadly i've just done as you've instructed and it still does nothing, can anyone else try it and see if works for them, maybe there's a conflict my end 🫣

using the shoulder buttons in either sequence, 5 > 6 or 6 > 5 work for me. to be clear, I swapped the numbers around in the script to check both sequences work as long as the script is written as so.

Link to comment
Share on other sites

I have a 8bitdo SN30 Pro connected via Bluetooth.

I added

$Esc::
{
WinClose, ahk_exe rpcs3.exe
}

in my running script of RPCS3 Emulator to exit the emulator when in game.

Is it possible to achieve this with with a button or combo button of the 8bitdo. I tried several scripts from this post without success.

Link to comment
Share on other sites

@Jack_77 In my testing I didn't need any special scripts to close RPCS3 with controller. I have the exact same controller and I use the controller mappings feature built into LaunchBox, it's under the "Main Menu -> Tools -> Options" all the way at the bottom. Here are a couple screenshots to show how I have mine setup.

RPCS3 under Manage -> Emulators
image.thumb.png.38487bc79eb6b62a250469091fa74338.png

And here is my controller mappings section
image.thumb.png.4fc618baf7eccf6b3a5071e6714e30ad.png

You'll notice I have my Button 7 + Button 8 set to Show Pause Screen, you can do that or if you just want to close the emulator set the Exit Game to a combo or button press. Just keep in mind that if you set it as a button combo you have to press them in order when in the emulator or it won't read it right.

Hope that helps

Link to comment
Share on other sites

@elwooha6 thanks a lot for the reply. I configured my buttons like yours but no success. I am testing this with WRC4 and i should say it´s my first RPCS3 game.

It seems that the button configuration in LB has no effect. I disabled gamepad in the emulator like this:

image.thumb.png.f00741dc6c2f32482bf21b4fba20e013.png

but none of the controller buttons work in game with buttons configured in LB.

Only way to get buttons work is to enable gamepad in Emulator like:

 image.thumb.png.cfb60c858991c1bd3f1dba7b2f495e1e.png

 

My emulator config:

image.thumb.png.b174aac6bd40deefe027a69196dd5325.png

image.thumb.png.7008418c7af06a5ee8eef36118f3e302.png

Link to comment
Share on other sites

On 1/13/2024 at 3:36 PM, JoeViking245 said:

Be sure you're pressing (and hold) the Left-Button (Joy5) BEFORE pressing the Right-Button (Joy6).

I swapped over controller to an original Xbox 360 i have kicking around, works spot on as you said it would 😁

Any ideas why it doesn't work with a "Power A enhanced  Xbox one/windows 10 controller", this does have 2 extra buttons underneath but they don't register on the PC, you can program these to act like the other buttons but i never have, in windows when i run "set up USB controller" the same buttons (5&6) are shown as working the same way on both controllers 🤔

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

its my config.

I used this code, but I still can't close the emulator. I tried the second joystick, but it still doesn't work. I hold down the button and press the second one after it, but it still doesn't come out.

 

image.png

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