FindWindow and SetForegroundWindow alternatives?

I am searching for alternatives to the old User32.dll version of switching to a different application with FindWindow() and SetForegroundWindow().

I did find an alternative to the first with the usage of Process.GetProcessesByName() but I do not see the corresponding method to switch (set active/foreground) to that application.

Is there a way of doing that without using the old way with the User32.dll?

Thank you for your help.


I accepted the answer of @Sorceri although it is not the answer I was looking for.


Answer: No.

But, to help the next wonderer looking to find a window and activate it from C# here's what you have to do:

static extern bool SetForegroundWindow(IntPtr hWnd);

void ActivateApp(string processName)
    Process[] p = Process.GetProcessesByName(processName);

    // Activate the first application we find with this name
    if (p.Count() > 0)

To bring notepad to the front, for example, you would call:


As a side note - for those of you who are trying to bring a window within your application to the foreground just call the Activate() method.

You could use SetActiveWindow as an alternative to SetForeGroundWindow. I'd say you should go through all the Windows Manipulation Api Functions and see if there's something you're missing out.

Also, note that you can obtain the handle of the System.Diagnostics.Process object via the Process.Handle property.

An alternative to SetForeGroundWindow is VisualBasic's AppActivate

Call it like this


Just because it is in the VisualBasic namespace doesn't mean you can't use it in C#.

Full Documentation here

You can use System.Diagnostics.Process Object for a FindWindow equivalent. There currently is no equivalent for SetForegroundWindow. You will want use Pinvoke with SetForgroundWindow.

static extern bool SetForegroundWindow(IntPtr hWnd);

Need Your Help

Curious arithmetic error- 255x256x256x256=18446744073692774400

c++ multiplication uint64

I encountered a strange thing when I was programming under c++. It's about a simple multiplication.

Matplotlib scatter plot with different text at each data point

python matplotlib text scatter-plot annotate

I am trying to make a scatter plot and annotate data points with different numbers from a list.