getRunningGameInfo2 monitorHandle value is 0 if game has not been previously focused

Issue Description:

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:

  1. Launch a Osu! (the app can already be running or launch when the game runs)
  2. While the splash screen in showing, focus on a Chrome window with the dev tools open.
  3. After Osu! and the app is loaded, enter overwolf.games.getRunningGameInfo2(console.log) into the dev consol.
  4. Expand the result to see that the monitorHandle.value is 0.
  5. Focus Osu!
  6. Re-enter overwolf.games.getRunningGameInfo2(console.log) into the dev consol.
  7. 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:

  1. Launch Osu!
  2. Wait for the game and app to finish loading completely.
  3. Go to the dev console and enter overwolf.games.getRunningGameInfo2(console.log).
  4. 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.

Overwolf version 0.195.0.18

Hi, thanks for highlighting this error! We will look it over from our end.

Hi DoctorOyster,

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.

have u try listen to onGameInfoUpdated event to track changes?

Hi Elad,

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.

we will try to reproduce it and look in to it

Hi Frederick!
Just wanted to update that this issue should be fixed in iteration 199, which will be releasing to developers soon

Thanks Oded!

1 Like

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

Noted. I’ll keep that in mind when I revisit the feature I was working on. Thanks.

1 Like