getRunningGameInfo2 / getRunningGameInfo has the monitor handle set to to 0 if the game has not been focused at least once after launching.
i.e. if you launch a game and keep the game window in focus while the app loads, then getRunningGameInfo2 will return a non-zero monitor handle. But if you unfocus the game window (alt + tab or click outside the game window) before the game loads, then the monitor handle is set to 0.
This is an issue because I need to check which monitor the game is running on when the game launches. If a user is using another program while they wait for the game to startup, then I wonât know which monitor the game window is on.
Can you reproduce it (exact steps to reproduce):
Testing was done with Osu! in windowed mode. The testing can be done with any app as the getRunningGameInfo2 command be be entered in the console.
Getting monitor handle to return 0:
Launch a Osu! (the app can already be running or launch when the game runs)
While the splash screen in showing, focus on a Chrome window with the dev tools open.
After Osu! and the app is loaded, enter overwolf.games.getRunningGameInfo2(console.log) into the dev consol.
Expand the result to see that the monitorHandle.value is 0.
Focus Osu!
Re-enter overwolf.games.getRunningGameInfo2(console.log) into the dev consol.
See that the monitorHandle.value is set to a non-zero number corresponding to the monitor the game is running on.
Getting the correct monitor handle value on game launch:
Launch Osu!
Wait for the game and app to finish loading completely.
Go to the dev console and enter overwolf.games.getRunningGameInfo2(console.log).
Expand the result to see that monitorHandle.value is non-zero
Impact for my app: [e.g. x% of the users complained about it, itâs a show-stopper]
Blocks feature if I canât determine the monitor a game is running on.
Do you currently have a workaround?
Can look into onGameInfoUpdated or onGameLaunched events. Maybe they can provide accurate monitor handles.
Please reproduce and attach a zip package of your OW client logs
Please mention the time of the event so we can find it easily in the logs getRunningGameInfo-monitorHandle-0-OverwolfLogs_2022-05-02_11-56-29.zip (1.5 MB)
May 2, 2022 11:54 AM test where I kept the game window in focus
May 2, 2022 11:55-56 AM test where I did not focus the game window when the game launched.
I ran into another issue with the getRunningGameInfo api. Sometimes the monitor handle value returned from getRunningGameInfo is incorrect. I donât have a guaranteed way to reproduce it though.
What I am trying to do:
move the desktop window to a second monitor when the app launches from a game being launched
What I did:
click the windows key on my keyboard
type âosuâ to search for the game Osu! and hit enter to launch the game
depending on which monitor my mouse is on, Osu! will launch on that monitor (I have Osu! in windowed mode if that makes a difference)
in some cases, only when Osu! launches on my second monitor, the monitor handle value is reported as the monitor handle for my primary display
this happened when I was closing and launching the game multiple times for testing. I was testing launching Osu! on the same monitor (primary and secondary) a few times in a row and launching Osu! on alternating monitors (primary then secondary and secondary then primary)
of the times when I received the incorrect monitor handle, it was always when Osu! launched on my secondary monitor. I think I also had Osu! in focus the whole time while it was launching.
As a work around I was able to use onGameInfoUpdated to listen to when the monitor handle is not 0, and I take that value to find the monitor the game opened on.
But I still get the issue in my second post in this thread, where the first non-zero monitor handle value is incorrect.
Hi!
So, after some testing, we found out a certain caveat to the fix (which is caused by a problem with windows), so we wanted to let you know in case you run into it in the future:
âWhen certain games are opened (usually games where the first window opened isnât the game itself, for example, GuildWars), if you change focus as soon as the game opens, âonGameLaunchedâ will return a monitor handle of 0. However, calling âgetRunningGameInfoâ in that case WILL return the correct monitor handle.â