From 192e315f9ff11a1d3d5121bf169b1b94c7c9e880 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 15:09:34 +0100 Subject: [PATCH 1/3] add qtcreator's .pro.user.* to gitignore --- .gitignore | 2 +- advancedSettings.pro.user.e9f45e7 | 318 ------------------------------ 2 files changed, 1 insertion(+), 319 deletions(-) delete mode 100644 advancedSettings.pro.user.e9f45e7 diff --git a/.gitignore b/.gitignore index 27860a8..92354b8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ Makefile* *.vs *.stash *.appxmanifest -*.user +*.user* diff --git a/advancedSettings.pro.user.e9f45e7 b/advancedSettings.pro.user.e9f45e7 deleted file mode 100644 index ab2fa5e..0000000 --- a/advancedSettings.pro.user.e9f45e7 +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - EnvironmentId - {e9f45e75-3f05-4ad6-a0dc-8a090aa48e0b} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.10.1 MSVC2017 64bit - Desktop Qt 5.10.1 MSVC2017 64bit - qt.qt5.5101.win64_msvc2017_64_kit - 0 - 0 - 0 - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - advancedSettings - advancedSettings2 - Qt4ProjectManager.Qt4RunConfiguration://192.168.1.165/win10/OpenVR-AdvancedSettings/advancedSettings.pro - true - - advancedSettings.pro - false - - C:/Users/robin/Documents/build-advancedSettings-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug/bin/win64/AdvancedSettings - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - From c57b9bc62d0ab9d46dd4938e5eca77b6687a994d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 15:26:59 +0100 Subject: [PATCH 2/3] specify dependency on qt >5.6 --- advancedSettings.pro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index d54a379..03159dc 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -4,10 +4,11 @@ # #------------------------------------------------- -QT += core gui qml quick multimedia +QT += core gui qml quick multimedia widgets CONFIG += c++11 -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5.6 or higher") +lessThan(QT_MINOR_VERSION, 6): error("requires Qt 5.6 or higher") TARGET = AdvancedSettings TEMPLATE = app From 8e2ca3602a24baf3afb9b831c4e53247f42e4eba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Dec 2018 16:32:38 +0100 Subject: [PATCH 3/3] Add option to send Alt-Tab as keyboard input --- src/res/qml/UtilitiesPage.qml | 16 +++- src/tabcontrollers/KeyboardInput.h | 1 + src/tabcontrollers/UtilitiesTabController.cpp | 4 + src/tabcontrollers/UtilitiesTabController.h | 1 + .../keyboardinput/KeyboardInputDummy.cpp | 5 ++ .../keyboardinput/KeyboardInputDummy.h | 1 + .../keyboardinput/KeyboardInputWindows.cpp | 82 +++++++++---------- .../keyboardinput/KeyboardInputWindows.h | 1 + 8 files changed, 62 insertions(+), 49 deletions(-) diff --git a/src/res/qml/UtilitiesPage.qml b/src/res/qml/UtilitiesPage.qml index 5a575ee..76841cf 100644 --- a/src/res/qml/UtilitiesPage.qml +++ b/src/res/qml/UtilitiesPage.qml @@ -45,7 +45,7 @@ MyStackViewPage { MyPushButton { text: "Keyboard Input" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { OverlayController.showKeyboard("", 601) } @@ -61,15 +61,23 @@ MyStackViewPage { MyPushButton { text: "Enter" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardEnter() } } + MyPushButton { + text: "Alt-Tab" + Layout.preferredWidth: 200 + onClicked: { + UtilitiesTabController.sendKeyboardAltTab() + } + } + MyPushButton { text: "Backspace" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardBackspace(1) } @@ -77,7 +85,7 @@ MyStackViewPage { MyPushButton { text: "10x Backspace" - Layout.preferredWidth: 250 + Layout.preferredWidth: 200 onClicked: { UtilitiesTabController.sendKeyboardBackspace(10) } diff --git a/src/tabcontrollers/KeyboardInput.h b/src/tabcontrollers/KeyboardInput.h index 28c2468..05fcfc0 100644 --- a/src/tabcontrollers/KeyboardInput.h +++ b/src/tabcontrollers/KeyboardInput.h @@ -16,6 +16,7 @@ public: virtual void sendKeyboardInput(QString input) = 0; virtual void sendKeyboardEnter() = 0; virtual void sendKeyboardBackspace(int count) = 0; + virtual void sendKeyboardAltTab() = 0; }; } diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 0ca7744..4cd203e 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -61,6 +61,10 @@ namespace advsettings { keyboardInput->sendKeyboardEnter(); } + void UtilitiesTabController::sendKeyboardAltTab() { + keyboardInput->sendKeyboardAltTab(); + } + void UtilitiesTabController::sendKeyboardBackspace(int count) { keyboardInput->sendKeyboardBackspace(count); } diff --git a/src/tabcontrollers/UtilitiesTabController.h b/src/tabcontrollers/UtilitiesTabController.h index 22e2f63..29d24e6 100644 --- a/src/tabcontrollers/UtilitiesTabController.h +++ b/src/tabcontrollers/UtilitiesTabController.h @@ -59,6 +59,7 @@ namespace advsettings { public slots: void sendKeyboardInput(QString input); void sendKeyboardEnter(); + void sendKeyboardAltTab(); void sendKeyboardBackspace(int count); void setAlarmEnabled(bool enabled, bool notify = true); diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp index f0ab55b..69054a9 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp @@ -17,4 +17,9 @@ void KeyboardInputDummy::sendKeyboardBackspace(int count) // noop } +void KeyboardInputDummy::sendKeyboardAltTab() +{ + // noop +} + } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h index 53b651c..f5ee302 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h +++ b/src/tabcontrollers/keyboardinput/KeyboardInputDummy.h @@ -12,6 +12,7 @@ public: virtual void sendKeyboardInput(QString input) override; virtual void sendKeyboardEnter() override; virtual void sendKeyboardBackspace(int count) override; + virtual void sendKeyboardAltTab() override; }; } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp index dfa1518..aafa129 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp @@ -17,6 +17,24 @@ void fillKiStruct(INPUT& ip, WORD scanCode, bool keyup) { ip.ki.time = 0; }; +void sendKeyboardInputRaw(int inputCount, LPINPUT input) { + if (!SendInput(inputCount, input, sizeof(INPUT))) { + char *err; + auto errCode = GetLastError(); + if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + errCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language + (LPTSTR)&err, + 0, + NULL)){ + LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; + } else { + LOG(ERROR) << "Error calling SendInput(): " << err; + } + } +} + void KeyboardInputWindows::sendKeyboardInput(QString input) { int len = input.length(); @@ -69,21 +87,8 @@ void KeyboardInputWindows::sendKeyboardInput(QString input) fillKiStruct(ips[ii++], VK_MENU, true); altPressed = false; } - if (!SendInput(ii, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)){ - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(ii, ips); delete ips; } } @@ -93,21 +98,8 @@ void KeyboardInputWindows::sendKeyboardEnter() LPINPUT ips = new INPUT[2]; fillKiStruct(ips[0], VK_RETURN, false); fillKiStruct(ips[1], VK_RETURN, true); - if (!SendInput(2, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)) { - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(2, ips); delete ips; } @@ -119,23 +111,23 @@ void KeyboardInputWindows::sendKeyboardBackspace(int count) fillKiStruct(ips[2 * i], VK_BACK, false); fillKiStruct(ips[2 * i + 1], VK_BACK, true); } - if (!SendInput(2 * count, ips, sizeof(INPUT))) { - char *err; - auto errCode = GetLastError(); - if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - errCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR)&err, - 0, - NULL)) { - LOG(ERROR) << "Error calling SendInput(): Could not get error message (" << errCode << ")"; - } else { - LOG(ERROR) << "Error calling SendInput(): " << err; - } - } + + sendKeyboardInputRaw(count * 2, ips); delete ips; } } +void KeyboardInputWindows::sendKeyboardAltTab() +{ + LPINPUT ips = new INPUT[4]; + // VK_MENU is alt + fillKiStruct(ips[0], VK_MENU, false); + fillKiStruct(ips[1], VK_TAB, false); + fillKiStruct(ips[2], VK_TAB, true); + fillKiStruct(ips[3], VK_MENU, true); + + sendKeyboardInputRaw(4, ips); + delete ips; +} + } diff --git a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h index 70318a5..3292b72 100644 --- a/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h +++ b/src/tabcontrollers/keyboardinput/KeyboardInputWindows.h @@ -12,6 +12,7 @@ public: virtual void sendKeyboardInput(QString input) override; virtual void sendKeyboardEnter() override; virtual void sendKeyboardBackspace(int count) override; + virtual void sendKeyboardAltTab() override; }; }