No, there is no easy way to add this behavior, but Windows is trying to do this automatically.
In theory, applications should not steal the foreground while you are actively using another application. Unfortunately, there are some scenarios in which Windows cannot distinguish between legitimate user actions that should change the foreground and unwanted theft of the foreground. The window manager usually tightens the holes slightly with each new version of Windows, but also needs to make sure that applications can come to the forefront when the user wants them, even if this desire is expressed indirectly.
For example, a process started by the current foreground process may place a window in the foreground. This is necessary so that when a user launches a window from Explorer, a recently launched process can open its main window. This permission is saved only until the next user input, so if the application starts slowly and you start working with e-mail, the application may lose foreground rights before it can use them.
See the SetForegroundWindow documentation for a list of requirements for a process to set a window to the foreground.
There are also applications that specifically use these requirements to steal permission (by attaching to the front-end queue or user input synthesizer for themselves), but I suspect this is an accident in your installer script.
I'm not sure what exactly is happening, but I suspect that the problem is with the installer running as a service and accidentally steals the foreground permission when it tries to run the application on your current desktop.
It would theoretically be possible for an external process to hook on the foreground system to redefine this and show your toast for confirmation, but it would be difficult to get right and require a significant low-level code (I would probably start with CbtHook ). This would not be possible in a scripting package such as AHK (assuming you mean AutoHotKey), but for this, C / C ++ code must be embedded in every running process.
source share