pina Posted December 23, 2020 Share Posted December 23, 2020 Before launching MAME, I need to use an AHK script to launch TouchMote before it launches MAME. That way my wii motes are detected by MAME. I created a script in AHK, compiled it. In my emulator settings, I pointed the mame executable to the compiled AHK script When testing out, TouchMote gets loaded, then MAME. But the problem now is. that I get redirected to the main menu of MAME instead of launching the game directly. What parameters do I have to add in order to launch the game instead of the MAME maine menu? Furthermore I can’t figure out how to exit TouchMote, if it’s running , after I quit the game... Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 23, 2020 Share Posted December 23, 2020 1 hour ago, pina said: What parameters do I have to add in order to launch the game instead of the MAME maine menu? Add %1% to the end of the Run, mame64.exe.... line. Run, "D:\Utils\TouchMote\touchmote.exe" RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %1%" WinClose, ahk_exe touchmote.exe RunWait will 'pause' the script until the .exe has exited. Then continue [to the next line]. (the quotes may or may not be needed.) Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 23, 2020 Share Posted December 23, 2020 Plan "B" (afterthought) Set mame64.exe as your emulator. Then in the Running AutoHotkey Script tab Run, "D:\Utils\TouchMote\touchmote.exe" $esc:: { WinClose, ahk_exe touchmote.exe WinClose, ahk_exe mame64.exe } Quote Link to comment Share on other sites More sharing options...
Headrush69 Posted December 23, 2020 Share Posted December 23, 2020 Why not compile your touchmote script and than add that as an application that runs before MAME when you edit the details of the game. Advantages of this is you don’t have to change default emulator settings and if you ever add something like LEDBlinky you won’t have issues with or issues with LB/BB seeing wrong application closures. Plus, I find it easier going back to a setup i did previously and seeing exactly how I set it up like this when parts/executable are separate tasks and you don’t have to worry about which script did what and launched which. Just my 2 cents, JoeViking245’s method is sound. ? 1 Quote Link to comment Share on other sites More sharing options...
pina Posted December 23, 2020 Author Share Posted December 23, 2020 4 hours ago, JoeViking245 said: Plan "B" (afterthought) Set mame64.exe as your emulator. Then in the Running AutoHotkey Script tab Run, "D:\Utils\TouchMote\touchmote.exe" $esc:: { WinClose, ahk_exe touchmote.exe WinClose, ahk_exe mame64.exe } I’ll try your proposals but about your plan B: I tried it before, using the script in LB directly, but the problem is that Mame starts up faster them Touchmote. Resulting in Mame loaded up, then Touchmotes a few seconds later. So my wii remotes aren’t detected by Mame since they need to be detected before Mame runs. I tried a sleep command and that doesn’t stop LB loading Mame of course, since launching Mame was not part of the script but part of Launchbox 1 hour ago, Headrush69 said: Why not compile your touchmote script and than add that as an application that runs before MAME when you edit the details of the game. Advantages of this is you don’t have to change default emulator settings and if you ever add something like LEDBlinky you won’t have issues with or issues with LB/BB seeing wrong application closures. Plus, I find it easier going back to a setup i did previously and seeing exactly how I set it up like this when parts/executable are separate tasks and you don’t have to worry about which script did what and launched which. Just my 2 cents, JoeViking245’s method is sound. ? I tried compiling the script in the first place, check my first post Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 23, 2020 Share Posted December 23, 2020 (edited) 31 minutes ago, pina said: Mame starts up faster them Touchmote Ya, I was afraid of that. Plan "C" would be what Headrush69 was leaning towards.... Keep the MAME Emulator unmodified, then for the games add a "Run before Main Application" Additional App that points to touchmote.exe. And then another Additional App that "Run After Main Application" that would either a) point to ../ThirdPaty/AutoHotkey/AutoHotkey.exe and uses the command line D:\path\to\file\ExitTouchMote.ahk or b) point to a compiled copy of ExitTouchMote.exe. Both of which have WinClose, ahk_exe touchmote.exe in it/them. Problem is you'd need to add that for all games in the Arcade Platform. Good thing is, if it's not already built into LB [yet?], there's a plugin in the Downloads area that will "(Bulk) Add Run Before/After Main Application" that adds an Additional Application to more than one game at one time. ....Maybe... ....I might not have uploaded it there. ? (attached) Or just stick with plan "A". Bulk Run Before-After.7z Edited December 23, 2020 by JoeViking245 1 Quote Link to comment Share on other sites More sharing options...
pina Posted December 23, 2020 Author Share Posted December 23, 2020 4 minutes ago, JoeViking245 said: Ya, I was afraid of that. Plan "C" would be what Headrush69 was leaning towards.... Keep the MAME Emulator unmodified, then for the games add a "Run before Main Application" Additional App that points to touchmote.exe. And then another Additional App that "Run After Main Application" that would either a) point to ../ThirdPaty/AutoHotkey/AutoHotkey.exe and uses the command line D:\path\to\file\ExitTouchMote.ahk or b) point to a compiled copy of ExitTouchMote.exe. Both of which have WinClose, ahk_exe touchmote.exe in it/them. Problem is you'd need to add that for all games in the Arcade Platform. Good thing is, if it's not already built into LB [yet?], there's a plugin in the Downloads area that will "(Bulk) Add Run Before/After Main Application" that adds an Additional Application to more than one game at one time. ....Maybe... ....I might not have uploaded it there. ? (attached) Or just stick with plan "A". Bulk Run Before-After.7z 34.06 kB · 0 downloads Ow I didn’t know there is a possibility to Add Run before/after main application. I think I prefer A more than C since it looks a bit cleaner. But about A, I was wondering what the function of %1% is? I don’t fully understand how LB could give a parameter to Mame so it knows which game to run? When launching directly, I guess that LB gives the command f.e. -samsho based on the title I click, but in the script, I don’t know how LB could give that parameter to Mame via AHS. Sorry if I explained it too difficult, perhaps I’m asking too many questions but I would like to understand what I’m doing instead of just copy paste is like a monkey Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 23, 2020 Share Posted December 23, 2020 %1% is a Parameter (or Variable) passed to the executable. In this case it's the rom_file_name (samsho). If you think of it as executing your compiled script from the command prompt, you'd type D:\> MameWithTouchMote.exe samsho "samsho" is the 1st (only) Parameter and the executable program stores that (reusable) Variable as %1% If say you had D:\> MameWithTouchMote.exe samsho astdelux Your compiled script could be like Run, "D:\Utils\TouchMote\touchmote.exe" RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %2%" ;run Asteroids Deluxe RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %1%" ;run Samurai Shodown RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %2%" ;run Asteroids Deluxe WinClose, ahk_exe touchmote.exe Variable. Reusable. Usable in any order. [Of course LB is not going to be passing multiple games to your executable. ] Quote Link to comment Share on other sites More sharing options...
Headrush69 Posted December 23, 2020 Share Posted December 23, 2020 2 hours ago, JoeViking245 said: Problem is you'd need to add that for all games in the Arcade Platform. Good thing is, if it's not already built into LB [yet?], there's a plugin in the Downloads area that will "(Bulk) Add Run Before/After Main Application" that adds an Additional Application to more than one game at one time. ....Maybe... ....I might not have uploaded it there. ? (attached) Totally forgot about that, good call. I think it's been on the poll to add as a feature, fingers crossed next one. 1 Quote Link to comment Share on other sites More sharing options...
pina Posted December 24, 2020 Author Share Posted December 24, 2020 3 hours ago, JoeViking245 said: %1% is a Parameter (or Variable) passed to the executable. In this case it's the rom_file_name (samsho). If you think of it as executing your compiled script from the command prompt, you'd type D:\> MameWithTouchMote.exe samsho "samsho" is the 1st (only) Parameter and the executable program stores that (reusable) Variable as %1% If say you had D:\> MameWithTouchMote.exe samsho astdelux Your compiled script could be like Run, "D:\Utils\TouchMote\touchmote.exe" RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %2%" ;run Asteroids Deluxe RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %1%" ;run Samurai Shodown RunWait, "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %2%" ;run Asteroids Deluxe WinClose, ahk_exe touchmote.exe Variable. Reusable. Usable in any order. [Of course LB is not going to be passing multiple games to your executable. ] I tried your first script. The runwait didn’t totally work because touchmote was loaded, but the wii remotes weren’t connected yet when the script launches Mame. So I addes a sleep command during a few seconds. So it works now. The last command doesn’t work though: WinClose. When quitting Mame, touchmote keeps running... I also have a strange behaviour. Sometimes when launching a title, it executes Touchmote two times resulting in an error message that it’s already active. When I just dismiss the message, go to mame then quit and try again, it won’t run touchmote twice again... Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 24, 2020 Share Posted December 24, 2020 1 hour ago, pina said: When quitting Mame, touchmote keeps running.. Maybe add another short Sleep after the RunWait line. Check task manager and see if touchmote.exe is launching a sub process (or something along those lines). Is MAME opening a command prompt window when you run this? [Actually ya, it probably is] Not sure if this'd help with the quitting issue, but it's probably better anyway. RunWait, %comspec% /c "D:\Emulators\MAME\mame64.exe -keyboardprovider dinput %1%",,Hide 1 hour ago, pina said: it executes Touchmote two times Did you clear out the Running AutoHotkey script tab? Could it still be running from the above issue? It will attempt to run it only as many times as you tell it to. If you can't find out where/why it's trying to run it twice (which you really should pin point that issue), you could get real crazy and replace that 1st line with something like if !WinExist("ahk_exe touchmote.exe") { Run, "D:\Utils\TouchMote\touchmote.exe" } If all else fails, there's still plan "C". But seriously, there no reason the above shouldn't work. Quote Link to comment Share on other sites More sharing options...
pina Posted December 25, 2020 Author Share Posted December 25, 2020 I really can’t get it working and it’s driving me crazy. So I just created a new script and only put this line in the code and compiled it: WinClose, ahk_exe touchmote.exe Touchmote just refuses to close. So I thought there was someting wrong with the syntax so I just replaced touchmote.exe with notepad.exe and that just works fine. So I thought maybe it’s because notepad.exe can be accessed from any folder. So I tried launchbox.exe: WinClose, ahk_exe launchbox.exe and yes, launchbox immediately closed... there’s something awkward with touchmote itself since it keeps refusing to quit... Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 25, 2020 Share Posted December 25, 2020 Can you close it from task manager? Try AHK Window Spy and see if you can see something there. Quote Link to comment Share on other sites More sharing options...
pina Posted December 25, 2020 Author Share Posted December 25, 2020 (edited) I’m getting crazy about this ? I try some other scripts with Touchmote, f.e.: if WinExist("ahk_exe Touchmote.exe") WinActivate, ahk_exe Touchmote.exe else Run, Touchmote.exe That runs fine, but when I change it just to WinClose instead of WinActivate it just won’t work at all ?? The only 1 command I need keep refusing to work while all other commands just work, It’s so hard to find the error. When running the script, just nothing happens, even no error message! My Windows Spy shows it’s the right process I chose. Even when I change it to pid, it doesn’t close at all. Whengoing to Task Manager, I can manually disable the process Edited December 25, 2020 by pina Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 25, 2020 Share Posted December 25, 2020 ...some more thoughts... Quote If a window does not close via WinClose, you can force it to close with WinKill. Quote Hidden windows are not detected unless DetectHiddenWindows has been turned on. https://www.autohotkey.com/docs/commands/WinClose.htm Quote Link to comment Share on other sites More sharing options...
pina Posted December 25, 2020 Author Share Posted December 25, 2020 So I tried the code in the remarks, so resulting in this code: #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 C:\Program Files\Touchmote ;Ensures a consistent starting directory. PostMessage, 0x112, 0xF060,,, ahk_exe Touchmote.exe ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE when I launch the script once, it does nothing. When I launch it again, then finally Touchmote quits. But always when I run the script a second time! I think this scripting tool is really mocking me. I can't see any logic explanation in such behaviour. I tried it on another Windows machine and have the same result. And no luck with either Hidden windows and WinKill Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted December 25, 2020 Share Posted December 25, 2020 Touchmote.exe is compiled as Admin according to the GitHub page. AHK can't close programs with higher privilege's than itself. With your compiled script that uses WinClose.....touchmote.exe, try setting the exe to run as Admin. Here some reading for ya (if you're so inclined). https://www.autohotkey.com/boards/viewtopic.php?t=60460 https://github.com/simphax/Touchmote/ https://www.autohotkey.com/boards/viewtopic.php?t=5262 Quote Link to comment Share on other sites More sharing options...
pina Posted December 27, 2020 Author Share Posted December 27, 2020 So I went to AHK forum too for some help and I got the pieces of the puzzle together now. It looks like it’s not a real admin issue, but it seems like the script just needs to be executed twice in order to quit Touchmote. I used the loop command to perform the WinClose command twice. But when compiled as an exe, I had to run it as admin. So I got it working finally... Thanks for your assistant 1 Quote Link to comment Share on other sites More sharing options...
thefritz11 Posted March 11, 2022 Share Posted March 11, 2022 On 12/27/2020 at 1:12 PM, pina said: So I went to AHK forum too for some help and I got the pieces of the puzzle together now. It looks like it’s not a real admin issue, but it seems like the script just needs to be executed twice in order to quit Touchmote. I used the loop command to perform the WinClose command twice. But when compiled as an exe, I had to run it as admin. So I got it working finally... Thanks for your assistant Sorry but would you be able post the exact script and how to implement? I have my wii motes working great with dolphin for Wii games but I believe I have to use touchmote before mame to get them to register in mame. I don't want to have to separately run touchmote play mame then quite before running a wii game so it sounds like your solution is exactly what I"m looking for. Quote Link to comment Share on other sites More sharing options...
pina Posted March 11, 2022 Author Share Posted March 11, 2022 3 hours ago, thefritz11 said: Sorry but would you be able post the exact script and how to implement? I have my wii motes working great with dolphin for Wii games but I believe I have to use touchmote before mame to get them to register in mame. I don't want to have to separately run touchmote play mame then quite before running a wii game so it sounds like your solution is exactly what I"m looking for. Wauw, I really have to dig very deep to answer you... Let me find out first myself because it's been almost 2 years... 😆 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.