0

I am having an issue with a certain program when calling it that it doesn't show in the screen, but only in the background with it's icon and title flashing in the taskbar.

However this doesn't happen when the program is minimized. It then opens in the foreground normally.

I don't want to use "Always on top" apps, as I generally call to edit those files from Explorer window or through Chrome.. etc.

How can I allow it always to come on focus when called? Or auto-minimize it when not on focus?

1 Answer 1

0

SetForegroundWindow

The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

The foreground window is the window at the top of the Z order. It is the window that the user is working with. In a preemptive multitasking environment, you should generally let the user control which window is the foreground window.

Windows 98/Me, Windows 2000/XP: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:

  • The process is the foreground process.

  • The process was started by the foreground process.

  • The process received the last input event.

  • There is no foreground process.

  • The foreground process is being debugged.

  • The foreground is not locked (see LockSetForegroundWindow).

  • The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).

  • Windows 2000/XP: No menus are active.

With this change [from Win 95/NT4], an application cannot force a window to the foreground while the user is working with another window. Instead, SetForegroundWindow will activate the window (see SetActiveWindow) and call the FlashWindowEx function to notify the user.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow

3
  • Thanks for the reply, that's some nice info.. but how can I actually through regedit or some tool achieve that with a certain program?
    – Mike
    Commented Jun 13, 2020 at 4:55
  • You need to comply with one of the 8 rules or you can't do it.
    – Mark
    Commented Jun 13, 2020 at 5:46
  • When I right click on the file, and then choose "Edit with program-name", it just flashes in the taskbar, and doesn't open/activate on the screen). I think this counts as "The process was started by the foreground process".
    – Mike
    Commented Jun 13, 2020 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .