Author Topic: Detect When Game Crashes?  (Read 1108 times)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Detect When Game Crashes?
« on: April 24, 2023, 08:35:58 PM »
Looking for a way to monitor the game process from within Voice Attack to know if the game client is unresponsive for x amount of time and if the game client itself ends and is no longer running.

Of course, if the game crashes, a LOST FOCUS could be one of the ways to get a hint on that, but that in no way tells if the game actually crashed or it's executable no longer running.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Detect When Game Crashes?
« Reply #1 on: April 25, 2023, 02:59:34 AM »
When you mention "the game process", which game are you referring to, specifically?

In which scenario would you the user not be aware that this game has crashed or frozen, before issuing a command?

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Detect When Game Crashes?
« Reply #2 on: April 25, 2023, 03:48:07 AM »
I have two Voice Attack Profiles being used for a game:

1. HCL Voice Packs pointing towards the game client with the 'Enable profile switching for the following windows or processes:' set to the game.

2. A Personal Profile in order to accomplish other things for supporting the game support because I don't have access to the HCL Voice Pack profile to do it, with that personal profile's commands being included in profile #1 above, and this profile does NOT have profile switching enabled for anything.

-------------

When the game client crashes, it keeps loaded Profile #1 as the active profile, and I presume any and all variables from both the above two profiles in their last known state in Voice Attack.

I have Profile #2 having a routine that loads up the game and all supporting 3rd party applications.
This profile also understands the latest state of various modes.
If I need to do a reset of all those things because of a game crash, then I'd like Voice Attack to know that was the case.

So I'd like to have Voice Attack know that game process is no longer running, return that situation to Profile #1 and prepare it for a reload of the game (minus already loaded 3rd party apps if need be) and a reset of the variable states.

----

I just thought that since Voice Attack has Profile Switching and the ability to recognize the game process, then it stands it maybe has some token or function or way in which to return the game process is either 'Not Responding' and or at least know it not longer is running.

Community thoughts/suggestions on how to handle/trap this case much appreciated.




Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Detect When Game Crashes?
« Reply #3 on: April 25, 2023, 05:09:29 AM »
The "{PROCESSEXISTS:}" token could be used to check whether an application is still running.


An inline function or plugin could theoretically use components of the System.Diagnostics namespace to monitor a process, E.G. the "Responding" property, and the "ExitCode" property

The former isn't necessarily applicable to all applications and all types of application crashes/freezes, as it basically just checks whether the main window's message loop is processing messages, however it should presumably be equivalent to what you'd see in task manager, or the pale overlay over the window itself when Windows assumes an application is not responding.

The latter can also be retrieved by enabling the "Wait until launched application is started before continuing" option and filling out the "Capture Exit Code to an integer variable" field of the "Run an Application" action, if you're using that to launch the game in question (and said game isn't using a separate process as a launcher)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Detect When Game Crashes?
« Reply #4 on: April 25, 2023, 05:21:59 AM »
Thanks Pfeil