Bring a window in your process to the foreground, even if a different process's window is currently in the foreground.
- Windows
- A .NET desktop runtime, such as
- .NET 5 or later
- .NET Core 3.1 or later
- .NET Framework 4.5.2 or later
dotnet add package Foregrounder
Foregrounder.Foregrounder.BringToForeground(myWindow);
myWindow
can be
- a
Window
from WPF - a
Form
from Windows Forms - an
AutomationElement
from UI Automation - a raw
HWND
window handle pointer
- Joseph Cooney for the original article and C# implementation
- Carl "Zodman" Scarlett for the StackOverflow answer that this package is based upon