WPF: Windows 8 Tabtip close?

回眸只為那壹抹淺笑 提交于 2019-12-12 03:49:09

问题


I've been searching and still can't find answers about this problem. i had managed to open the process of the tab tip by this code:

Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles TextBox1.GotFocus

Process.Start("C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")

End Sub

ive been trying to kill the process but still it won't work.

But returning it to dock or closed. still can't find any answers.Is this possible? hope someone cud help. thanks! :)


回答1:


/// <summary>
/// Close Touch Keyboard
/// </summary>
public static void CloseTouchKeyboard()
{
    try
    {
        foreach (var p in Process.GetProcessesByName("C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe"))
        {
            p.Kill();
        }
    }
    catch (Exception e)
    {
        Logger.Error(e.ToString());
    }
}

/// <summary>
/// Open Touch keyboard
/// </summary>
public static void OpenTouchKeyboard()
{
    try
    {
        Process.Start("C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe");
    }
    catch (Exception e)
    {
        Logger.Error(e.ToString());
    }
}



回答2:


The Process.Close, CloseMainWindow, etc did not work for me, so send this message to close the keyboard.

[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);

int WM_SYSCOMMAND = 274
uint SC_CLOSE   = 61536
...

IntPtr KeyboardWnd = FindWindow("IPTip_Main_Window", null);
PostMessage(KeyboardWnd , WM_SYSCOMMAND, SC_CLOSE, 0);

Thanks to http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/de9b66b5-f1e2-477c-9da2-303982790f63/ for the answer!



来源:https://stackoverflow.com/questions/15183720/wpf-windows-8-tabtip-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!