It is very easy to obtain access to an external running window and activate it. All you need is the actual title of the window ( the text written in the titlebar of the window) and FindWindow and SetForegroundWindow APIs.
FindWindow gets access to the window in question. SetForegroundWindow activates the window thus bringing it to the front. Here is a small example:
using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices; //required for APIsnamespace Find{public partial class Form1 : Form{//Import the FindWindow API to find our window[DllImportAttribute("User32.dll")]private static extern int FindWindow(String ClassName, String WindowName);//Import the SetForeground API to activate it[DllImportAttribute("User32.dll")]private static extern IntPtr SetForegroundWindow(int hWnd);public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){//Find the window, using the CORRECT Window Title, for example, Notepadint hWnd = FindWindow(null, "Untitled - Notepad");if (hWnd > 0) //If found{SetForegroundWindow(hWnd); //Activate it}else{MessageBox.Show("Window Not Found!");}}}}
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.




















