查找屏幕键盘的类名? [英] Finding the class name of the On-Screen Keyboard?
本文介绍了查找屏幕键盘的类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用这个的代码示例从C#(.NET 3.5)WinForms应用程序控制Windows XP屏幕键盘(OSK.exe):
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");
}
我如何确定准确的className?我假设CaptionName是屏幕键盘
How do I determine the accurate className? I assume that the CaptionName is 'On-Screen Keyboard'.
推荐答案
貌似类名是:OSKMainClass
Looks like the classname is: "OSKMainClass"
下面是我用找到这个代码。这只是一个简单的C#窗体应用程序
Here is the code I used to find this. It's just a simple 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());
}
从以下来源的激活任意窗口利用API
和的 MSDN GetClassName功能
这篇关于查找屏幕键盘的类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文