Right now I'm trying to programmatically toogle the numeric layout for the Windows 8.1 onscreen keyboard also called "virtual keyboard" or "soft input panel (SIP)".
It's not a WPF solution where I can set the InputScope, but I'm using a JavaFX application on a Windows 8.1 tablet. I know there is a built-in onscreen keyboard for JavaFX, but the metro style SIP (tabtip.exe) is called for.
My current solution looks like this; I simulate a mouse click on the lower left corner of the keyboard where the "&123" button is with C#. Compile this snippet into an .exe and call it from JavaFX e.g. when a TextField with numeric input receives focus. This has obvious downsides:
1) It's hacky
2) If the keyboard is in floating state and moved or some other screen-resolution is in place, the click coordinates might not be in the right spot.
3) The app needs elevated privileges to spawn mouse events on the SIP
What is a better way to do this?
I've tried using Spy++ to analyse and found a "TipSkinEvent" when I press the "&123" button.
Based on I came up with this:
void ToggleNum()
{
HWND hwndInputPanel = ::FindWindow(_TEXT("IPTip_Main_Window"), NULL);
DWORD WM_NUM_BUTTON_PRESSED = ::RegisterWindowMessage(_TEXT("TipSkinEvent"));
PostMessage(hwndInputPanel, WM_NUM_BUTTON_PRESSED, 0, 0);
}
This doesn't work, and unfortunately I'm no expert in Windows programming thus I have no clue what has to be done here. Can you tell me what is wrong in the snippet or what the correct API is to change the layout as seen in the picture above? (Setting the numeric flag in the windows registry yields a different layout - and also needs admin rights to kill and restart tabtip.exe)
To toggle the keyboard visibility I use a similar approach (calling C# code compiled into an .exe) This works fine (even without elevated privileges!). Based on
A sidenote: I also tried to use JNA to skip the .exe call with no success.