Jump to content
LaunchBox Community Forums

Scripting noob


snax087

Recommended Posts

Hey fellas, ive gotten a few answers here before when i first began my arcade emulation build and i have run into a problem and this seems to be a solid place to turn. My issue is not with launchbox/bigbox but another front end that i am using for a friend's arcade build that i did for him. When a game is launched through Retroarch, there is a brief moment in between the hand off from the frontend to the RA window where if any button is pressed it will cause the RA window to lose focus and not accept input until it is Alt+Tab'd back into focus. I have no experience with scripting so my question is, is it possible to have a script or program run in the background that looks for Retroarch.exe and ensure it is the focused window when it is launched or even periodically while it's running? I was looking at this thread here

 and it seems to be similar to what i need but i'm not 100% sure. Any help would be much appreciated as everything runs perfectly except for this small flaw. I would like to point out that I have tried to replicate this with MAME as well but it no matter how many buttons i push when it launches it doesnt lose focus like Retroarch ? Thanks

Link to comment
Share on other sites

It's very difficult to answer your question directly because your situation is virtually unknown to me. But autohotkey has a WinActivate command. https://www.autohotkey.com/docs/commands/WinActivate.htm

Something like:

#NoEnv
SetTitleMatchMode, 2
WinWait, RetroArch ahk_class RetroArch
Sleep 5000                              ;set for delay. 1000ms is 1 second.
WinActivate,

Of course you can make the script more complicated with WinActive https://www.autohotkey.com/docs/commands/WinActive.htm and run the script in a loop.

But as a first step I myself would investigate the focus loss by finding out which program steals the focus.

Edited by Koroth
Link to comment
Share on other sites

48 minutes ago, Koroth said:

It's very difficult to answer your question directly because your situation is virtually unknown to me. But autohotkey has a WinActivate command. https://www.autohotkey.com/docs/commands/WinActivate.htm

Something like:


#NoEnv
SetTitleMatchMode, 2
WinWait, RetroArch ahk_class RetroArch
Sleep 5000                              ;set for delay. 1000ms is 1 second.
WinActivate,

Of course you can make the script more complicated with WinActive https://www.autohotkey.com/docs/commands/WinActive.htm and run the script in a loop.

But as a first step I myself would investigate the focus loss by finding out which program steals the focus.

Thanks for the reply. I’ll try that once I get home. I think the front end is retaining focus because in that short window of time where RA is starting up, the front end is still the active window until RA starts up and pressing a key in that time keeps the focus on the front end and disrupts the focus handoff to the RA window. It doesn’t do it with MAME at all, only RA.

Do AHK scripts always require a key to execute them or can it be run on startup and stay running in the background without any input from the user? I guess it would be ideal if the script could be running from boot up to check every x seconds to see if RA is running and if it is  to run the WinActive command on it to bring it to focus if it already isn’t. I have zero experience with this but I definitely want to try and learn to fix this.

 

Link to comment
Share on other sites

22 minutes ago, snax087 said:

Thanks for the reply. I’ll try that once I get home. I think the front end is retaining focus because in that short window of time where RA is starting up, the front end is still the active window until RA starts up and pressing a key in that time keeps the focus on the front end and disrupts the focus handoff to the RA window. It doesn’t do it with MAME at all, only RA.

For me RetroArch starts fullscreen and gets focus immediately and stays that way. Although, I have to say, I don't use LaunchBox/Bigbox in a cabinet. Just for couch gaming. In the RetroArch options maybe you could try a different rendering API or check if the option "Windowed Full screen" is disabled, to get it more stable. Also check if your frontend uses something like startup screen that mask the hand off and could interfere.

22 minutes ago, snax087 said:

Do AHK scripts always require a key to execute them or can it be run on startup and stay running in the background without any input from the user? I guess it would be ideal if the script could be running from boot up to check every x seconds to see if RA is running and if it is  to run the WinActive command on it to bring it to focus if it already isn’t. I have zero experience with this but I definitely want to try and learn to fix this.

No autohoykey scripts don't require a key. The whole point is to automate tasks and can be run at startup via various ways. Yes, a script can run in the background and we can come up with a script that works. Quite often you can edit an existing script to suit your needs (adapt it to RetroArch.) But by far the easiest way is to execute such a script via the frontend. LaunchBox/BigBox can.

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