sirgubster9 Posted March 7, 2022 Share Posted March 7, 2022 (edited) I am trying to use this app called keyboard2xinput I can in theory have it load easily using the section available on launchbox, but I need it to close after i close that rom. the only way I can normally close it is by going down to the taskbar right clicking on it and pressing exit. I posted this question on the forum for that software and I recieved this info and i thought since you guys know more abotu programming and more about launchbox you could instruct me how to do this: Setup Launchbox to point to custom AHK script instead of games exe. This is example of one of my AHK: Code: [Select] #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance, Force #Persistent Run D:\Games\Keyboard2Xinput\Keyboard2XinputGui.exe Sleep, 1000 ; sleep 1 second Run D:\Games\Game shortcuts\DoubleDragon.exe.lnk Sleep, 1000 ; sleep 1 second proc1 = DoubleDragon.exe Process, Wait, %proc1% Process, WaitClose, %proc1% SendInput {NumpadMult} ExitApp Once windows process DoubleDragon ends AHK sends * NumpadMult which closes Keyboard2Xinput Edited March 7, 2022 by sirgubster9 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 7, 2022 Share Posted March 7, 2022 2 hours ago, sirgubster9 said: the only way I can normally close it is by going down to the taskbar right clicking on it and pressing exit. According to the script, you can press the asterisk ( * ) on the number pad to close keyboard2xinput. Can you 1st verify that pressing that key does indeed work for you? If it doesn't, setting up this script won't do any good. Just sayin'. And if it does work, setup LaunchBox to point to custom AHK script instead of the games exe. To do this: Create a new text file and save it to somewhere you won't forget nor accidentally delete. Say somewhere like "D:\Games\Double Dragon\" Inside that text file, copy and paste the code you found above. Be sure that the paths on the TWO separate lines that start with Run are pointing to the correct paths and files for your app and game. Save the file, but save it with an "ahk" file extension. I.e. "MyDoubleDragon.ahk". (make sure it doesn't save as "MyDoubleDragon.ahk.txt") In LaunchBox, Edit your Double Dragon game Go to the Launching section. Where it says Application Path: click Browse and navigate to and select ../LaunchBox/ThirdParty/AutoHotkey/AutoHotkey.exe Where it says Application Command-Line Parameters:, type in the full path to where you saved the file you created above. And put quotes around it. i.e. "D:\Games\Double Dragon\MyDoubleDragon.ahk" Click OK to save and close. Play Double Dragon. 1 Quote Link to comment Share on other sites More sharing options...
sirgubster9 Posted March 7, 2022 Author Share Posted March 7, 2022 1 hour ago, JoeViking245 said: According to the script, you can press the asterisk ( * ) on the number pad to close keyboard2xinput. Can you 1st verify that pressing that key does indeed work for you? If it doesn't, setting up this script won't do any good. Just sayin'. And if it does work, setup LaunchBox to point to custom AHK script instead of the games exe. To do this: Create a new text file and save it to somewhere you won't forget nor accidentally delete. Say somewhere like "D:\Games\Double Dragon\" Inside that text file, copy and paste the code you found above. Be sure that the paths on the TWO separate lines that start with Run are pointing to the correct paths and files for your app and game. Save the file, but save it with an "ahk" file extension. I.e. "MyDoubleDragon.ahk". (make sure it doesn't save as "MyDoubleDragon.ahk.txt") In LaunchBox, Edit your Double Dragon game Go to the Launching section. Where it says Application Path: click Browse and navigate to and select ../LaunchBox/ThirdParty/AutoHotkey/AutoHotkey.exe Where it says Application Command-Line Parameters:, type in the full path to where you saved the file you created above. And put quotes around it. i.e. "D:\Games\Double Dragon\MyDoubleDragon.ahk" Click OK to save and close. Play Double Dragon. you are a genius and a saint. everything worked perfectly..... almost. Only issue is whenever i run the game on launchbox everything goes according to plan except it gets an error after its been open for say 10 seconds and has to close down? When I run it without launchbox no problems and when i run it through launchbox but not as a AHK no problems so im assuming something to do with that code is causing an issue, any ideas? Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 8, 2022 Share Posted March 8, 2022 Glad to help! Are you Running the games exe file? Or are you using a shortcut to the exe (like the script is indicating)? Any reason not to use the exe directly? If you can run 'DoubleDragon.exe' directly, try something like: Run, D:\Games\Keyboard2Xinput\Keyboard2XinputGui.exe Sleep, 1000 ; sleep 1 second RunWait, D:\Games\DoubleDragon.exe SendInput, {NumpadMult} "RunWait" will start DoubleDragon.exe and hang around until it's no longer running. When it's not running anymore, then, and only then will it press the asterisk key. The script will then exit itself. You don't need all the other stuff in the script. Oh, again... make sure the path to the exe(s) is (are) correct. Quote Link to comment Share on other sites More sharing options...
sirgubster9 Posted March 8, 2022 Author Share Posted March 8, 2022 17 hours ago, JoeViking245 said: Glad to help! Are you Running the games exe file? Or are you using a shortcut to the exe (like the script is indicating)? Any reason not to use the exe directly? If you can run 'DoubleDragon.exe' directly, try something like: Run, D:\Games\Keyboard2Xinput\Keyboard2XinputGui.exe Sleep, 1000 ; sleep 1 second RunWait, D:\Games\DoubleDragon.exe SendInput, {NumpadMult} "RunWait" will start DoubleDragon.exe and hang around until it's no longer running. When it's not running anymore, then, and only then will it press the asterisk key. The script will then exit itself. You don't need all the other stuff in the script. Oh, again... make sure the path to the exe(s) is (are) correct. I am running the exe and not the shortcut, dont know why his code was using a shortcut but I changed that. I tried using your code exactly and just got rid of everything else and sadly same results. Well not exactly I obviously pointed it to my stuff. But ya still same issue of error and game closing. oh new idea that you can probably help me with. what if I run the game exe using launchbox normally and then i have additional apps run the other keyboardinput app. and now that I know asterix closes the app is there anyway to have the esc button be esc plus asterix? is there a macro or something that would allow me to do that? Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 8, 2022 Share Posted March 8, 2022 1 hour ago, sirgubster9 said: But ya still same issue of error and game closing. What exactly is the error saying? Can you take a screenshot of it? 1 hour ago, sirgubster9 said: what if I run the game exe using launchbox normally and then i have additional apps run the other keyboardinput app. Sure. Step 1: Start by adding (or editing) the game. Go to the Launching section and Browse to your DoubleDragon.exe file. Next go to the Emulation section and make sure the box is unchecked. Click OK to save and close. Now (for testing and process of elimination purposes) open Windows Explorer and navigate to where your "Keyboard2XinputGui.exe" file is located. Click it and press Enter so that it loads/launches/runs/starts/does-what-it-does. Now go back to LaunchBox and launch your DD game. Play it a little. Do you still get the "error"? If so, what does it say? If not, Exit the game as you normally would. (Usually you go to a menu and select "Quit to Windows" or something like that) You should now be back in LaunchBox. Press the asterisk on your numpad. Does "Keyboard2XinputGui.exe" exit? Step 2: ..to follow, depending on the results of Step 1. 1 Quote Link to comment Share on other sites More sharing options...
sirgubster9 Posted March 8, 2022 Author Share Posted March 8, 2022 attached are screen shots of error. and followed step 1 and everything worked perfectly. Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 8, 2022 Share Posted March 8, 2022 I have nofa-king idea what Windjammers 2 is. That's a totally different game, isn't it??? Anyway, since step 1 worked.. Step 2: Edit your game (again) and go to the Additional Apps section. Click Add Application. Give it a fancy Application Name like "Keyboard2XinputGui". Next Browse to and select your "Keyboard2XinputGui.exe" file. Now check the box for Automatically Run Before Main Application. Click OK. And Click OK again. Now the fun part. Create a new text file and in it put: SendInput, {NumpadMult} ExitApp Save the file somewhere where you won't forget where it is. Maybe in the same folder as your "Keyboard2XinputGui.exe" file is. Like with everything else, give it a fancy name like "ExitK2X". Now rename the file to have an .ahk file extension. like "ExitK2X.ahk". Be careful that it doesn't get renamed "ExitK2X.ahk.txt". (Probably could have this last part 1st...) Edit your game once again. Go to Additional Apps section. Click Add Application. Give it a fancy Application Name like "Exit Keyboard2XinputGui". Next Browse to and select "AutoHotkey.exe". You'll find one in /LaunchBox/ThirdParty/AutoHotkey/ In the Application Command-Line Parameters field, type the full path to where you save the .ahk file, and put it in quotes. Example: "D:\Games\Keyboard2Xinput\ExitK2X.ahk" Make sure you have the correct path. Now check the box for Automatically Run After Main Application. Click OK. And Click OK again. Make sure Keyboard2XinputGui isn't already running. Launch your game via LaunchBox. 1 Quote Link to comment Share on other sites More sharing options...
sirgubster9 Posted March 8, 2022 Author Share Posted March 8, 2022 you are unbelievably good at explaining things over text. I super wish I had your skills for dealing with my parents and there computer problems. You saved the day, works perfectly.....but one final question, i realize now that this game doesn't exit when I press ESC. i think its a steam game kind of but do you know of away to be able to exit it with esc? If not thats totally cool im guessing this question has been asked a bunch and I can search around for it. And finally dudeeeeeeeeeeee i am very insulted that you havent heard of windjammers....you need to do me a favor and go and play the greatest game of all time WINDJAMMERS!!!!!!!!!!!! its seems simple on the surface but it is soooooo gosh dang fun, now to play it on an arcade cabinet is the best, but other platforms will do as well i guess. and this is windjammers 2, just came out and ive never really played it so i cant vouch for it yet but since its a sequel to the greatest game ever its got to at least be ok. 1 Quote Link to comment Share on other sites More sharing options...
sirgubster9 Posted March 8, 2022 Author Share Posted March 8, 2022 oh i just realized that there is a quit on the main menu of the game so if its super complicated to come up with a way to have ESC exit the game that's fine, I think most people will see the big EXIT on the menu ha ha Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 9, 2022 Share Posted March 9, 2022 4 hours ago, sirgubster9 said: do you know of away to be able to exit it with esc? Yes. But you'd be back to square one using a script similar to the one you started with. And we see where that got you. Also, it always advised to use a games built in exit sequence when available. Glad to hear the keyboard2Xinput is now working well for you!! 1 Quote Link to comment Share on other sites More sharing options...
AceEsCloud Posted March 30, 2023 Share Posted March 30, 2023 (edited) Hello, I have a set of commands that I saved into a .bat file and am using the "running scrips" section of launchbox to run the .bat file when the program launchs. The .bat file opens a program and sets some parameters that allows a DMD to run when playing future pinball. I need it to also run another .bat file too upon exit though which will close the DMD. I don't know anything about AHK scripting and that is why I wrote the .bat files instead. Here is what I currently tried to use in the running scripts section and although it worked to launch the first .bat, it did not work to launch the second during exit; run, "C:\Visual Pinball\VPinMAME\Launchboxscript.bat" $Esc:: run, "C:\Visual Pinball\VPinMAME\Launchboxexitscript.bat" Note: If I knew AHK scripts, I probably wouldn't have had to make .bat files in the first place, but I don't know... Here are the contents of the .bat files if it helps; Launch script; c <--with a colon like a drive letter (forums turn it into a smiley face...) cd "C:\Visual Pinball\VPinMAME" start /min "" "dmdext.exe" mirror --source=futurepinball -q --virtual-stay-on-top --fps 60 -g "[GAMENAME]" --use-ini="C:\Visual Pinball\VPinMAME\DmdDevice.ini" Exit Script; taskkill /f /im "dmdext.exe" Any help is greatly appreciated! Edited March 30, 2023 by AceEsCloud Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted March 30, 2023 Share Posted March 30, 2023 12 hours ago, AceEsCloud said: it did not work to launch the second during exit If you're using FPLoader to launch your tables, it never will. The Running script only stays active while the 'emulator' (FPLoader.exe in this case) is running. If I recall correctly, FPLoader is essentially a launcher for 'Future Pinball.exe'. So as soon as it launches it, it itself closes. Thus, closing out the Running Script making the escape sequence unavailable. Steam is the same way. So if you need to run something after playing a Steam game, you're in the same boat. 'Nature of the beast'. The Fix: Create a new "emulator". Unless you know how to "wait for an application to not exist [anymore]" (Future Pinball.exe in this case) using a batch file, we'll have to learn ya' some AHK. Create a new text document. ("FP-DMD.txt" or whatever) In there, put: Run, "dmdext.exe" mirror --source=futurepinball -q --virtual-stay-on-top --fps 60 -g "[GAMENAME]" --use-ini="C:\Visual Pinball\VPinMAME\DmdDevice.ini", C:\Visual Pinball\VPinMAME, Min Run, "C:\Future Pinball\BAM\FPLoader.exe" /play /exit /open "%1%" Sleep, 10000 While WinExist("ahk_exe Future Pinball.exe") sleep 700 Process, Close, dmdext.exe ExitApp Adjust the 2nd Run command to point where your FPloader.exe is located. Save to somewhere convenient to you, Close and change the file extension to .ahk ("FP-DMD.ahk"). Be careful that it's not saving it as ""FP-DMD.ahk.txt". In LaunchBox, Add a new Emulator. Name the emulator (FP-DMD or whatever you want) Browse to and set the Application Path to ..\LaunchBox\ThirdParty\AutoHotkey\AutoHotkey.exe Note: once selected, LaunchBox will show it as a relative path. In the Default Command-Lin Parameters: enter the full path to the AHK file you created, in quotes. In the Associated Platforms section (select it on the left), Add "Future Pinball" (or whatever the exact name of your platform is). Assuming all your FP tables will be using dmdext, check the box for Default Emulator. You'll probably be asked, Do you want to make this the default emulator?. Yes. Click OK to save and close. Play a table (or two) Quote Link to comment Share on other sites More sharing options...
AceEsCloud Posted March 31, 2023 Share Posted March 31, 2023 This worked perfectly the first time! I have to say I am extremely impressed with your post and the time / effort you put into helping me. I greatly appreciate you taking the time to help! 1 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.