locked
Open and close tabtip.exe from a VB.net 2010 application RRS feed

  • Question

  • Hi,

    I have spent some time trying to open and close tabtip.exe dynamicaly on Windows 8. I have tried to reference microsoft.ink.dll but I have not been able to get anywhere. I can open the tabtip.exe application on Windows 7, but using the same method in Windows 8 produces a e-fail error.

    Does anyone know of some sample code in VB.NET that works under Windows 8?

    Should I use microsoft.ink? - Or is there another way of reaching the keyboard from VB?

    On the other hand.... I may be making this more difficult than it is? - Could there be some in built functionality in Windows 8 or for instance VB.NET 2012?

    Any insight is welcome.

    John

    Monday, February 11, 2013 12:25 PM

Answers

  • Hi John,

    Thanks for your feedback. I'm using a 64 Bit Windows 8 , and the following codes work on my PC, which will open the touch keyboard, and close it.

    Imports System.Threading
    Imports System.Runtime.InteropServices
    
    Public Class Form2
        Dim WM_SYSCOMMAND As Int32 = 274
        Dim SC_CLOSE As UInt32 = 61536
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
        End Function
    
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindow( _
        ByVal lpClassName As String, _
        ByVal lpWindowName As String) As IntPtr
        End Function
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Process.Start("C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim TouchhWnd As New IntPtr(0)
            Dim hWnd As New IntPtr(0)
            TouchhWnd = FindWindow("IPTip_Main_Window", Nothing)
            'If ..
            'Else..
            PostMessage(TouchhWnd, WM_SYSCOMMAND, SC_CLOSE, 0)
        End Sub
    End Class

    The marked solution in the article above didn't work on windows 8, bu the solution by Ryand do works. As quoted below:

    For Windows 8:

    Note: Just like the Windows 7 solution, this requires an elevated process.

    The input panel is not a descendant of HWND_DESKTOP. (It's probably some kind of Metro window.) In order to get the window handle, do a series of horizontal sweeps in a grid-like pattern testing with WindowFromPoint(). For each test, check the window class of the parent window to see if it is "IPTip_Main_Window".

    To show the input panel, launch "C:\\Program Files\\Common Files\\microsoft shared\\ink\\tabtip.exe". To determine if it is already in docked mode, read registry key:

    HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7\EdgeTargetDockedState

    A value of 0 indicates the input panel is in floating mode. If that was the case, post the following message to toggle the docked state:

    DWORD WM_DOCK_BUTTON_PRESSED = ::RegisterWindowMessage(_TEXT("IPTipDockButtonPressed"));

    PostMessage(hwndInputPanel, WM_DOCK_BUTTON_PRESSED, 0, 0);

    To hide the keyboard, post the following:

    PostMessage(hwndInputPanel, WM_SYSCOMMAND, SC_CLOSE, 0);

    If I misunderstood anything, please feel free to let me know.

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by John1969 Wednesday, February 13, 2013 8:16 AM
    Wednesday, February 13, 2013 3:14 AM

All replies

  • Hi John,

    Welcome to the MSDN forum.

    Seems the touch keyboard(tablip.exe) is redesigned on Windows 8, and here's a some steps to control it on Windows 8 using C++ by Ryand, http://stackoverflow.com/questions/1770670/how-do-i-control-the-text-input-panel-programmatically-tabtip-exe-in-windows-v, this use Windows messages, I think it should work in .NET.

    Hope this helps.

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by John1969 Tuesday, February 12, 2013 11:22 AM
    • Unmarked as answer by John1969 Tuesday, February 12, 2013 11:22 AM
    Tuesday, February 12, 2013 8:50 AM
  • Hi Shanks,

    Thanks for your reply, but both suggestions in that article have been updated by the authors, they have submitted that the answers do not work on Windows 8 (both for different reasons).

    I can confirm that these suggested solutions do not work, as-is.

    Any other suggestions?

    John.

    Tuesday, February 12, 2013 11:22 AM
  • Hi John,

    Thanks for your feedback. I'm using a 64 Bit Windows 8 , and the following codes work on my PC, which will open the touch keyboard, and close it.

    Imports System.Threading
    Imports System.Runtime.InteropServices
    
    Public Class Form2
        Dim WM_SYSCOMMAND As Int32 = 274
        Dim SC_CLOSE As UInt32 = 61536
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
        End Function
    
        <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
        Private Shared Function FindWindow( _
        ByVal lpClassName As String, _
        ByVal lpWindowName As String) As IntPtr
        End Function
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Process.Start("C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim TouchhWnd As New IntPtr(0)
            Dim hWnd As New IntPtr(0)
            TouchhWnd = FindWindow("IPTip_Main_Window", Nothing)
            'If ..
            'Else..
            PostMessage(TouchhWnd, WM_SYSCOMMAND, SC_CLOSE, 0)
        End Sub
    End Class

    The marked solution in the article above didn't work on windows 8, bu the solution by Ryand do works. As quoted below:

    For Windows 8:

    Note: Just like the Windows 7 solution, this requires an elevated process.

    The input panel is not a descendant of HWND_DESKTOP. (It's probably some kind of Metro window.) In order to get the window handle, do a series of horizontal sweeps in a grid-like pattern testing with WindowFromPoint(). For each test, check the window class of the parent window to see if it is "IPTip_Main_Window".

    To show the input panel, launch "C:\\Program Files\\Common Files\\microsoft shared\\ink\\tabtip.exe". To determine if it is already in docked mode, read registry key:

    HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7\EdgeTargetDockedState

    A value of 0 indicates the input panel is in floating mode. If that was the case, post the following message to toggle the docked state:

    DWORD WM_DOCK_BUTTON_PRESSED = ::RegisterWindowMessage(_TEXT("IPTipDockButtonPressed"));

    PostMessage(hwndInputPanel, WM_DOCK_BUTTON_PRESSED, 0, 0);

    To hide the keyboard, post the following:

    PostMessage(hwndInputPanel, WM_SYSCOMMAND, SC_CLOSE, 0);

    If I misunderstood anything, please feel free to let me know.

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by John1969 Wednesday, February 13, 2013 8:16 AM
    Wednesday, February 13, 2013 3:14 AM
  • Hi Shanks,

    Great answer! This works.

    The Elevated Process is key here.

    Thanks again!

    John

    Wednesday, February 13, 2013 8:21 AM