首页 > 代码库 > Win8环境WPF打开和关闭软键盘
Win8环境WPF打开和关闭软键盘
代码如下:
public class KeyBoardHelper { #region 键盘控制 /// <summary> /// 显示键盘 /// </summary> public static void ShowInputPanel() { string path = @"C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe"; string path32 = @"C:\Program Files (x86)\Common Files\Microsoft Shared\Ink\TabTip32.exe"; if (File.Exists(path)) { Process.Start(path); } else if (File.Exists(path32)) { Process.Start(path32); } } #region import 软键盘 [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 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, uint wParam, uint lParam); #endregion /// <summary> /// 隐藏屏幕键盘 /// </summary> 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); } #endregion }
Win8环境WPF打开和关闭软键盘
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。