I have been trying to get the onscreen keyboard (osk.exe
) to appear (and disappear) on Windows 10 from within my app. My app was running fine in windows 7. Calling ShellExecute()
on osk.exe
would show the keyboard there but trying to get the same behaviour in Windows 10 has proved to be a pain.
To try to hide the keyboard, once it is visible, I tried this:
HANDLE wHandle = FindWindowW(L"OSKMainClass", L"On-Screen Keyboard");
if (wHandle != NULL)
{
long style = GetWindowLong(wHandle, GWL_STYLE);
if (style & WS_VISIBLE)
{
return TRUE;
}
else
{
SetWindowLongPtr(wHandle, GWL_STYLE, WS_VISIBLE);
}
but that had no effect.
I also tried using the TabTip keyboard but was unable to detect when it is visible (I can detect when it's not visible but I can't get a handle to it when it is visible!).
Any help with this problem would be appreciated.
Update: The reason osk
wasn't initially been shown was the 'nCmdShowparameter supplied to
ShellExecute`, the original code supplied NULL for this value and it was working fine on Windows 7 so I had assumed the problem lay elseware. changing it from NULL to SW_SHOWNORMAL fixed the issue with the keyboard appearing.
Comment by Paul Sanders: In a 32 bit app you have to do one more thing, see, see: https://stackoverflow.com/a/50510526/5743288.