简体   繁体   中英

How to open tabtip keyboard in a custom location?

How can I open the tabtip keyboard in a custom location?

This is my code:

Private tabtipProcess As Process

Private Sub t_Enter(sender As Object, e As EventArgs)
    tabtipProcess = Process.Start("tabtip")
End Sub

[Undeleted answer to provide a solution if the OP decides to use a third party application instead]

- For the record, you cannot seem to programmatically change the location of tabtip.

You can P/Invoke (also known as Platform Invoke ) the WinAPI's SetWindowPos() function and send your process's MainWindowHandle to it. Then you just specify the coordinates where you want to put the window.

<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
End Function

Const SWP_NOSIZE As Integer = &H0001

Private tabtipProcess As Process

Private Sub t_Enter(sender As Object, e As EventArgs)
    tabtipProcess = Process.Start("tabtip")
    tabtipProcess.WaitForInputIdle()
    SetWindowPos(tabtipProcess.MainWindowHandle, IntPtr.Zero, 300, 200, 0, 0, SWP_NOSIZE)
End Sub

The above example will put the window at coordinates (300, 200).

The tabtipProcess.WaitForInputIdle() call is necessary as it is used to wait until the application has finished loading and a window handle has been created. Without it tabtipProcess.MainWindowHandle will most likely return 0 and result in an error when calling the SetWindowPos() function.

Passing the SWP_NOSIZE flag tells the function that the window should retain its current size.

After finally testing my previous answer I can confirm that (as you said) it doesn't work, so I did some research.

There are a few others that have also wanted to change its location, so after reading a few posts and after I performed some testing myself, it would seem that the tabtip application has been designed to trap certain window messages (more specifically WM_MOVE and/or WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED ) which makes you unable to change its location or size programmatically using the standard methods.

At this point there doesn't seem to be a way to modify its location.

You can do this by altering the registry values of the tabtip.

Like this:

 My.Computer.Registry.SetValue(
    "HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7",
    "OptimizedKeyboardRelativeXPositionOnScreen",
    &HDB1D,
    Microsoft.Win32.RegistryValueKind.DWord
)
My.Computer.Registry.SetValue(
    "HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", 
    "OptimizedKeyboardRelativeYPositionOnScreen",
    &H12016,
    Microsoft.Win32.RegistryValueKind.DWord
)

The two hex values are the locations of your x and y.

Geoff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM