From a8d94208b9b705cd28bfe79b227f2fc4637faf05 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Fri, 11 Mar 2016 14:48:51 +0100 Subject: [PATCH] Enable hiding OSK on Windows --- src/frameworks/UBPlatformUtils_win.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/frameworks/UBPlatformUtils_win.cpp b/src/frameworks/UBPlatformUtils_win.cpp index eac3ae45..8f717504 100644 --- a/src/frameworks/UBPlatformUtils_win.cpp +++ b/src/frameworks/UBPlatformUtils_win.cpp @@ -439,11 +439,19 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) void UBPlatformUtils::showOSK(bool show) { - Q_UNUSED(show); - - QString windir = qgetenv("WINDIR"); - QString osk_path = windir+"\\System32\\osk.exe"; - - QProcess newProcess; - newProcess.startDetached("explorer.exe", QStringList() << osk_path); + if (show) { + QString windir = qgetenv("WINDIR"); + QString osk_path = windir+"\\System32\\osk.exe"; + + QProcess oskProcess; + // We have to pass by explorer.exe because osk.exe can only be launched + // directly with administrator rights + oskProcess.startDetached("explorer.exe", QStringList() << osk_path); + } + + else { + HWND oskWindow = ::FindWindow(TEXT("OSKMainClass"), NULL); + if (oskWindow) + PostMessage(oskWindow, WM_SYSCOMMAND, SC_CLOSE, 0); + } }