Looking for an on-screen keyboard class name?

I am trying to use this code sample to control the Windows XP on-screen keyboard (OSK.exe) with 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 to determine the exact class name? I assume that CaptionName is an On-Screen Keyboard.

+1
source share
1 answer

It looks like the class name: "OSKMainClass"

Here is the code I used for this. This is just a C # Forms App

  [DllImport("User32.dll")] public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("user32.dll")] public static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] public static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int hWnd = FindWindow(null, "On-Screen Keyboard"); StringBuilder buffer = new StringBuilder(128); GetClassName(hWnd, buffer, buffer.Capacity); MessageBox.Show(buffer.ToString()); } 

Get it from the following sources Activate any window using the API and GetClassName MSDN Function

+3
source

All Articles