levi Posted October 29, 2016 Posted October 29, 2016 I'm using BigBox on a cabinet in a semi public location. If someone chooses a game and walks away, I didn't want MAME running indefinitely. I would rather return to BigBox so the next person knows he can choose a game. I used the following script to exit MAME if there is no input for two minutes. In LaunchBox's Manage Emulators window, choose MAME and Edit Emulator. Then, on the AutoHotkey Script tab, enter the following: Quote #Persistent SetTimer, Check, 6000 return Check: IfGreater, A_TimeIdle, 120000, Process, Close, {{{StartupEXE}}} Hope it works for someone else too! Quote
spotUP Posted June 4, 2024 Posted June 4, 2024 Awesome! I am also running a cab at work, this is just what i needed! Quote
paddyG Posted Thursday at 11:43 AM Posted Thursday at 11:43 AM (edited) Does that AHK script above still work? I've copied and pasted it into the Running Scripts section under Edit Emulator (Retroarch), but nothing happens after 120 seconds... any game that uses Retroarch (mame-libretro) just keeps running. I've also used this AHK in Running Scripts with Retroarch a few years ago and it worked well, but I stopped using it. I wanted to start using it again but it is not working on the latest LB version: #Persistent SetTimer, Check, 6000 return SendMode Event Check: IfGreater, A_Timeidle, 120000 { SetKeyDelay, -1, 110 Send {Escape} Sleep, 1000 Send {Escape} } I'm using Windows 10 Pro, Launchbox version 13.22. I've tried Beta 13.23 too, but same thing... nothing happens. It's like the AHK is not executing from Running Scripts when the emulator starts. I can manually press Escape two times and Retroarch will quit. So, why can't I do this with AHK in Running Scripts? Edited Thursday at 11:54 AM by paddyG Quote
JoeViking245 Posted Thursday at 01:01 PM Posted Thursday at 01:01 PM 1 hour ago, paddyG said: Does this AHK script still work? I've copied and pasted this into the Running Scripts section under Edit Emulator (Retroarch), but nothing happens after 120 seconds... any game that uses Retroarch (mame-libretro) just keeps running. Windows 10 Pro, Launchbox version 13.22. I've tried Beta 13.23 too, but same thing... nothing happens. It's like the AHK is not executing from Running Scripts when the emulator starts. I've never tested it, but looking at it, it should. As for running Arcade games using RetroArch vs. stand-alone MAME, that's a different thorn. To explain what the script is doing, it's checking every 6 seconds. During "the check", if there's been no keyboard presses or mouse movement for a cumulative of 2 minutes, it will (should) close the app. So if you touch the mouse at all (or press a key), A_TimeIdle resets to 0. To verify the script at least started, below #Persistent, you can add a line MsgBox, script started. (Though you might not be able to see the message box behind the Loading Screen. And... it might pause the script until you click OK.) Quote
paddyG Posted Thursday at 04:44 PM Posted Thursday at 04:44 PM Thanks JV... I added MsgBox, script started after #Persistent and disabled -f and startup screen so I could see the game open in RA window. When I launched the game, I saw the message pop up and it said the script was running. I clicked ok and the message box closed. I clicked the RA window to make sure it was active and I watched the game demo play in the active RA window for 5 minutes and it did not exit. There was nothing disturbing the mouse or keyboard or any other input device, all idle the whole time. I have RA set to quit with Escape key, and also "confirm quit" is on, so Escape has to be pushed twice to actually quit RA. I disabled "confirm quit" to see if that changed anything, but it did not. I know we verified the script is running, but it seems it is not actually sending the Escape key (x2). I've also tried this script in Running Scripts, but same... it does not quit Retroarch: #Persistent SetTimer, Check, 6000 return Check: IfGreater, A_Timeidle, 300000 { WinClose, ahk_exe {{{StartupEXE}}} } return $Q:: { WinClose, ahk_exe {{{StartupEXE}}} } Quote
JoeViking245 Posted Thursday at 06:24 PM Posted Thursday at 06:24 PM 54 minutes ago, paddyG said: I know we verified the script is running, but it seems it is not actually sending the Escape key (x2). If you disabled Confirm, it's not even sending Escape once. Well, it is actually sending it. It's just that RA is not receiving it. There's some fancy shmancy things you can do to make it work that way. But since we're just trying to close the emulator, let's just cut to the chase. Which is what you did in your last post. But I think (not totally sure), the 2nd Return might be 'causing issues'. The Q hotkey is redundant to pressing Escape. But if you'd rather press Q than Escape, then go ahead and keep it in there. Lastly, when testing, be sure to wait the w h o l e 5 minutes (300,000ms) plus 6 seconds +/- for the initial 'check'. #Persistent SetTimer, Check, 6000 return Check: IfGreater, A_Timeidle, 300000 WinClose, ahk_exe {{{StartupEXE}}} ;optional $Q::WinClose, ahk_exe {{{StartupEXE}}} This worked for me. (5 minutes was a long arse time to wait for a test. But I waited. ) But fortunately/unfortunately, this is the exact same thing as the OP. Except with a different wait/idle time, using WinClose (which is preferred over Process, Close) and formatting out the WinClose line (which functionally, doesn't make a difference [similar to my 'Q' hotkey]). That said, not sure what else to tell ya. Quote
paddyG Posted 19 hours ago Posted 19 hours ago Thanks JV, I tried that script, but no-joy. Must be some permissions issue with RA. I'll keep digging. I'm like a dog with a bone with this. I might spend the weekend building everything from scratch. I just wanna play pac-man, man! Quote
paddyG Posted 15 hours ago Posted 15 hours ago I figured out the culprit is Joy2Key. When J2K is running, the exit on idle AHK in Running Scripts does not execute... I guess maybe J2K is causing some disturbance to the idle timer in the background. When I close J2K, and run the game in LB/BB with RA, the AHK runs as expected and closes the game/emulator once the idle time is met. Hmmm... how to use J2K and have this script do it's thing at the same time? Quote
paddyG Posted 14 hours ago Posted 14 hours ago Google to the rescue! Had to add "hooks" for mouse and keyboard, and use A_TimeidlePhysical to the AHK. I changed the idle time to 10000 for testing purposes so I'm only waiting 10 seconds to check results. So now it looks like this, and it works! Whoo-Hooo!!! #Persistent #InstallKeybdHook #InstallMouseHook SetTimer, Check, 6000 return SendMode Event Check: IfGreater, A_TimeIdlePhysical, 10000 { SetKeyDelay, -1, 110 Send {Escape} Sleep, 1000 Send {Escape} } Thanks again JV for helping me yesterday... I owe you a very large coffee! Quote
paddyG Posted 13 hours ago Posted 13 hours ago Well, I spoke too soon. The running script works too well. I set the check time to 300000, and the game exited while I was playing! Back to the drawing board... Quote
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.