C# 调用Win8系统键盘

private const Int32 WM_SYSCOMMAND = 274;
private const UInt32 SC_CLOSE = 61536;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int RegisterWindowMessage(string lpString);

//显示屏幕键盘
public static int ShowInputPanel()
{
try
{
dynamic file = "C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe";
if (!System.IO.File.Exists(file))
return -1;
Process.Start(file);
return SetUnDock();
}
catch (Exception)
{
return 255;
}
}

//隐藏屏幕键盘
public static void HideInputPanel()
{
IntPtr TouchhWnd = new IntPtr(0);
TouchhWnd = FindWindow("IPTip_Main_Window", null);
if (TouchhWnd == IntPtr.Zero)
return;
PostMessage(TouchhWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
}

 

C# 调用Win8系统键盘,布布扣,bubuko.com

C# 调用Win8系统键盘

上一篇:实时开发框架Meteor API解读系列<八> Timers


下一篇:在windows下运行Felzenszwalb的Deformable Part Model(DPM)源码voc-release3.1来训练自己的模型