-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows .exe loses focus to AM if keys are pressed during launch #220
Comments
FWIW I believe we ran into this too at the arcade we setup. Luckily we were on hand to correct if it happened. But for folks setting up permanent installations without supervision around, this is pretty deal breaker problem to have :( |
Would love to get a response on this issue! Is there a way to make sure that games are launched in the foreground with keyboard focus on Windows when using Attract Mode? |
Ok, so I have tried to reproduce this using the most recent attract-mode, mame, and the orbit theme (which has a fade to game effect) on windows 10. I'm just using the keyboard keys, and so far I am unable to reproduce. I'm launching the program and then mashing random keys while the "fade out" occurs. Are you able to reproduce this reliably or is it a relatively rare occurrence? Also, please post the emulator configuration file that you are running the windows programs with. thanks. |
Hi Andrew thanks for your help! I'm using the 2.0.0 download from the website and the orbit theme on Windows 8. I'm however launching Windows games using the windows_games emulator and NOT using MAME. I can recreate the bug 100% of the time by pressing enter to launch a game and then immediately spamming the Up key on my keyboard. The game will either launch in the background or it will be in the foreground but without keyboard focus. I'm seeing this across several games built with different engines (Unity and others). My windows_games emulator file is attached. |
I've been working on a fix on my own, and it looks like one method would be to just find and focus the root window of the launched process (or, if that process is cmd /c and doesn't have a window, its child process). It's pretty ugly code still, but it seems to fix the problem. For reference and verification, my emulator config attached: |
OK, I am now confident that my change is dealing with the problem. For myself, that's good and I'll continue to use an altered version of the launcher. I don't think my code is necessarily what you'd want to use if you choose to address this in the main repo (let me know if you want it anyway). The gist is that Attract Mode has focus, and therefore can grant focus to whichever other process it would like via SetForegroundWindow, SetWindowPos, or what have you. The HWND you want to pass focus to may belong to a child of the child process launched by AM, so you have to grovel around in various enumeration functions (I used CreateToolhelp32Snapshot and EnumWindows as my base, with GetAncestor to deal with weird apps that don't create their top-level window first). Finally, since the window may not be created right away, run_program needs to try this whole process periodically in it's wait loop (every one or half-second works for me). Let me know if you want more details! CreateToolHelp32Snapshot: |
Hi, first time Attract Mode user and poster here! I'm building a cabinet that will run a handful of locally-made games under Windows 8.
We're having a problem where AM keeps/steals focus if the player starts a game and then presses keys during the brief fade-down that AM does.
There are two flavors of this:
I just updated to 2.0.0 from 1.6.4, no change.
I've tried:
I'm kind of at a loss for other ideas! Any help is appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: