otavioraposojr Posted November 11, 2020 Share Posted November 11, 2020 (edited) Pretty much a self explanatory title. I want to implement an autohotkey script that open/closes BetterJoy when running/closing a game on Dolphin alone. 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. Edited November 11, 2020 by otavioraposojr Quote Link to comment Share on other sites More sharing options...
LegzRwheelz Posted November 12, 2020 Share Posted November 12, 2020 So, I would suggest you checking out rocketlauncher. It is overwhelming for beginners, however, it's very powerful. Even if you don't implement it into your lb setup, you can learn how it launches games and with that, this can learn a lot about using AHK. I'm not near my setup right now to type out a test script for you but you can create a blank AHK script and run it, from there you can right click on it in the system tray and go to WindowSpy. Then launch your game in dolphin, it will give you the window title that's needed to create a launcher script. If you want, you can pm me and I'll try to get you straightened out, I see a lot of trial and error with this ?. What say you, @JoeViking245 about this. Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted November 12, 2020 Share Posted November 12, 2020 (edited) I strongly would not recommend rocketlauncher. As you said, it is overwhelming for beginners. And by now very out of date and interferes with the working of LaunchBox. The few advantages rocketlauncher has over LaunchBox I could live without. Go to Tools > Manage Emulators > Dolphin > Running AutoHotKey Script tab. Add: Run, "path\to\BetterJoyForCemu.exe" $Esc:: { WinClose, ahk_exe BetterJoyForCemu.exe } *By "path\to\BetterJoyForCemu.exe" of course I mean de path to the BetterJoyForCemu folder and executable.* Edited November 12, 2020 by Koroth 1 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted November 12, 2020 Share Posted November 12, 2020 I don't use RocketLauncher, so I'm not in a position to say anything good or bad about it other than what I'd get out of it isn't worth the pain it is to A) figure out how to set it up, then B) actually get it setup, and lastly C) have it actually work. I think @Koroth's script is the cleanest way to do this. I don't know if BetterJoy needs to be running BEFORE Dolphin starts, but as I think about it, it would make sense that the Running AutoHotkey Script setup for the emulator would execute before having the emulator launch the game. Koroth, have you personally used this as the Running AutoHotkey Script for starting (and stopping) BetterJoy? (you didn't say and I know nothing about BetterJoy ) Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted November 12, 2020 Share Posted November 12, 2020 14 minutes ago, JoeViking245 said: Koroth, have you personally used this as the Running AutoHotkey Script for starting (and stopping) BetterJoy? (you didn't say and I know nothing about BetterJoy ) I tested this script with starting and stopping and that worked as it should. On my computer the BetterJoy windows appears about 1 sec. before Dolphin's. However I don't own any Nintendo controllers, so I can't verify BetterJoy actually works. 1 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted November 12, 2020 Share Posted November 12, 2020 Just did a little testing with this and it seems the Escape hotkey here messes with closing the emulator. For my tests I used notepad.exe instead BetterJoy. The Running AutoHotkey Script does indeed load BEFORE LaunchBox has the emulator run the game. But when I hit Escape, Notepad (in my sample test) closes, but Dolphin (also tested with MAME) does not. When I hit Escape again, it still doesn't close. Verified Dolphin had focus and still wouldn't close with Escape. So plan "B" (verified to work with Notepad and Dolphin) run, notepad.exe $esc:: { WinClose, ahk_exe notepad.exe WinClose, ahk_exe dolphin.exe } @otavioraposojr Just replace "notepad.exe" (2 spots) with your BetterJoy executable filename ("BetterJoyForCemu.exe"?) and put this is the Running AutoHotkey Script tab as Koroth said. run, "full\path\to\BetterJoyForCemu.exe" $esc:: { WinClose, ahk_exe BetterJoyForCemu.exe WinClose, ahk_exe dolphin.exe } (Of course changing the "full\path\to\" in the 1st line) 1 1 Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted November 12, 2020 Share Posted November 12, 2020 @JoeViking245 You are probably right about adding dolphin.exe to $Esc:: On my setup it worked without, but that is probably specific to my setup. But can I ask you a question? How do you get a white background to appear behind your script in your post. That makes the script stand out and easy to read/copy! Quote Link to comment Share on other sites More sharing options...
Retro808 Posted November 12, 2020 Share Posted November 12, 2020 @Koroth Just use the <> (code) option in the text box when you post a response. Right above the text box you will see the brackets. That's for posting code text. 1 Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted November 12, 2020 Share Posted November 12, 2020 3 minutes ago, Retro808 said: @Koroth Just use the <> (code) option in the text box when you post a response. Right above the text box you will see the brackets. That's for posting code text. Thank you! (BTW, this was a test.) 1 Quote Link to comment Share on other sites More sharing options...
otavioraposojr Posted November 13, 2020 Author Share Posted November 13, 2020 (edited) @JoeViking245 I've a problem with the "esc" solution. I use Big Box, and I close the games not by using the esc key on computer keyboard, but by pressing the share button on my Nintendo Pro Controller (configured to "Close Active Window" in Big Box options). I use this as a "universal closer" to all emulators, because it makes everthing much easier. I tested the script and BetterJoy will not close precisely because I'm not closing using the esc key. Any way around that? Edited November 13, 2020 by otavioraposojr Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted November 13, 2020 Share Posted November 13, 2020 2 hours ago, otavioraposojr said: "Close Active Window" in Big Box options That's an interesting way to close an emulator. Well, I should say that's new to me. But if it works, great! Any chance you tested it by pressing Escape on your keyboard? Just curious. Because if that doesn't work, neither will the following. And using Escape (just for initial testing purposes) makes it easier to troubleshoot if there are issues. Similar to Esc:: before, but using the joy button run, "full\path\to\BetterJoyForCemu.exe" 1Joyx:: { WinClose, ahk_exe BetterJoyForCemu.exe WinClose, ahk_exe dolphin.exe } Replace the "x" in "1Joyx::" with the button number corresponding to the "Close Active Window" button you setup in BigBox. (It should show you the button 'number'). For example, if it says 'button 12', you'd use "1Joy12::". Quote Link to comment Share on other sites More sharing options...
Retro808 Posted November 13, 2020 Share Posted November 13, 2020 7 hours ago, otavioraposojr said: @JoeViking245 I've a problem with the "esc" solution. I use Big Box, and I close the games not by using the esc key on computer keyboard, but by pressing the share button on my Nintendo Pro Controller (configured to "Close Active Window" in Big Box options). I use this as a "universal closer" to all emulators, because it makes everthing much easier. I tested the script and BetterJoy will not close precisely because I'm not closing using the esc key. Any way around that? As long as the program uses "Escape to close, using Escape command in AHK should still work even though you have bound a button to "Close Active Window". How LB/BB controller automation works is LB/BB uses the button you mapped to send "Escape" to close the active window. LB waits a few seconds and if LB is not in focus (meaning the emulator has not closed) it will then send "Alt+F4" and try again. Jason even put in some of the unique close command like Ctrl+F9 for DOSBox. Now, it some emulators may be a little more stubborn and need tweaking. It could be possible BetterJoy does not like "Escape" to close. If you just open BetterJoy and hit Escape does it close? It may prefer Alt+F4. Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted November 14, 2020 Share Posted November 14, 2020 3 hours ago, Retro808 said: It could be possible BetterJoy does not like "Escape" to close. If you just open BetterJoy and hit Escape does it close? It may prefer Alt+F4. @Retro808 In this case "Escape" isn't used to close BetterJoy. "Escape" just sends the autohotkey "WinClose" command, which closes BetterJoy. @otavioraposojr BetterJoy has a checkbox to "Start in Tray". Make sure that is unchecked. If you did, start the game and double click on the BetterJoy tray icon and uncheck. Autohotkey's "WinClose" command does not work with apps that solely reside in the system-tray. (Usually they need to be force closed.) Quote Link to comment Share on other sites More sharing options...
Retro808 Posted November 14, 2020 Share Posted November 14, 2020 13 minutes ago, Koroth said: @Retro808 In this case "Escape" isn't used to close BetterJoy. "Escape" just sends the autohotkey "WinClose" command, which closes BetterJoy. Good point. I did not read the whole thread, just the post I replied to. That's what I get for partially reading. Quote Link to comment Share on other sites More sharing options...
otavioraposojr Posted November 14, 2020 Author Share Posted November 14, 2020 (edited) Thank you for the replies. I tested the script again and it worked with the "esc" solution, even using the button on the joystick. It works even with "Start in Tray" checked. It's all good. Edited November 14, 2020 by otavioraposojr Quote Link to comment Share on other sites More sharing options...
Molinski44 Posted December 2, 2020 Share Posted December 2, 2020 This is really neat. Is this possible with Citra and CEMU as well? Basically same principle when launched from big box betterjoy opens and when emulator exits betterjoy closes? Quote Link to comment Share on other sites More sharing options...
The Papaw Posted December 17, 2020 Share Posted December 17, 2020 On 11/12/2020 at 2:12 AM, Koroth said: I strongly would not recommend rocketlauncher. As you said, it is overwhelming for beginners. And by now very out of date and interferes with the working of LaunchBox. The few advantages rocketlauncher has over LaunchBox I could live without. Go to Tools > Manage Emulators > Dolphin > Running AutoHotKey Script tab. Add: Run, "path\to\BetterJoyForCemu.exe" $Esc:: { WinClose, ahk_exe BetterJoyForCemu.exe } *By "path\to\BetterJoyForCemu.exe" of course I mean de path to the BetterJoyForCemu folder and executable.* This is working great for me running DS4Windows. I added to the emulator start script. How do I kill the process using AHK when I leave the emulator/exit game? Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted December 17, 2020 Share Posted December 17, 2020 32 minutes ago, Wanderer189 said: This is working great for me running DS4Windows. I added to the emulator start script. How do I kill the process using AHK when I leave the emulator/exit game? Try: $Esc:: { WinClose, ahk_exe DS4Windows.exe } If that doesn't work try: $Esc:: { Process, Close, DS4Windows.exe } Quote Link to comment Share on other sites More sharing options...
The Papaw Posted December 17, 2020 Share Posted December 17, 2020 4 minutes ago, Koroth said: Try: $Esc:: { WinClose, ahk_exe DS4Windows.exe } If that doesn't work try: $Esc:: { Process, Close, DS4Windows.exe } I tried them both, will I need to edit path for them to match how I am calling it? Run, "D:\Program Files (Portable)\DS4Windows\DS4Windows.exe" $Esc:: { WinClose, ahk_exe DS4Windows.exe } Quote Link to comment Share on other sites More sharing options...
Your Friendly A.I Overlord Posted December 17, 2020 Share Posted December 17, 2020 You can close a program by using a window title/class name or a process name. You don't need a full path for that (if I understand you correctly.) Let me know if it works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.