I am attempting to use this code sample to control the Windows XP On-Screen Keyboard (OSK.exe) from a C# (.NET 3.5) Winforms application:
[DllImport("User32.dll")]public static extern Int32 SetForegroundWindow(int hWnd);
[DllImport("user32.dll")]public static extern int FindWindow(string lpClassName, string lpWindowName);
private void BringToFront(string className,string CaptionName)
{
SetForegroundWindow(FindWindow(className,CaptionName));
}
private void Form1_Load(object sender, EventArgs e)
{
BringToFront("Notepad", "Untitled - Notepad");
}
How do I determine the accurate className? I assume that the CaptionName is ‘On-Screen Keyboard’.
Looks like the classname is: “OSKMainClass”
Here is the code I used to find this. It’s just a simple C# Forms App
Got this from the following sources Activate Any Window With API
and MSDN GetClassName function