From 65a313fb4e4126db0dcedeb967cbc0fca5c696c0 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Mon, 3 Jun 2024 15:07:45 +0300 Subject: [PATCH 01/24] Test version --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +- .../SettingsXAML/Views/GeneralPage.xaml | 2 +- .../SettingsXAML/Views/GeneralPage.xaml.cs | 2 + .../ViewModels/GeneralViewModel.cs | 43 +++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 78affbb16f13..4230a2b198d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,7 +7,8 @@ body: - type: markdown attributes: value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- type: input +- id: version + type: input attributes: label: Microsoft PowerToys version placeholder: 0.70.0 diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml index 4ffa0bf4a999..65a0d12b6b0d 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml @@ -367,7 +367,7 @@ - + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs index ed29e2e9f6d7..c01a1da87c16 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs @@ -84,6 +84,8 @@ public GeneralPage() DataContext = ViewModel; doRefreshBackupRestoreStatus(100); + + ViewModel.InitializeReportBugLink(); } private void OpenColorsSettings_Click(object sender, RoutedEventArgs e) diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index 8d55056f64d4..9079d3c58ee1 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; @@ -11,6 +12,8 @@ using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading.Tasks; +using System.Web; +using CommunityToolkit.WinUI.Helpers; using global::PowerToys.GPOWrapper; using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; @@ -18,6 +21,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; +using Windows.System; namespace Microsoft.PowerToys.Settings.UI.ViewModels { @@ -177,7 +181,46 @@ public GeneralViewModel(ISettingsRepository settingsRepository, private string _settingsBackupMessage; private string _backupRestoreMessageSeverity; + private string reportBugLink; + // Gets or sets a value indicating whether run powertoys on start-up. + public string ReportBugLink + { + get => reportBugLink; + set + { + reportBugLink = value; + OnPropertyChanged(nameof(ReportBugLink)); + } + } + + public void InitializeReportBugLink() + { + var version = HttpUtility.UrlEncode(GetPowerToysVersion()); + + var gitHubURL = "https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + + "&version=" + version; + + ReportBugLink = gitHubURL; + } + + private string GetPowerToysVersion() + { + return "0.88.0"; // Replace with the actual method to get the version. + } + + private string GetOSVersion() + { + // Implement a method to get the OS version + return "OS_VERSION_PLACEHOLDER"; + } + + private string GetDotNetVersion() + { + // Implement a method to get the .NET version + return "DOT_NET_VERSION_PLACEHOLDER"; + } + public bool Startup { get From 96c09532fadb992dfe20523f8eb28247ab300827 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Mon, 3 Jun 2024 15:09:23 +0300 Subject: [PATCH 02/24] Github URL --- src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index 9079d3c58ee1..a2ce031a7eb1 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -198,7 +198,7 @@ public void InitializeReportBugLink() { var version = HttpUtility.UrlEncode(GetPowerToysVersion()); - var gitHubURL = "https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + + var gitHubURL = "https://github.com/gokcekantarci/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + "&version=" + version; ReportBugLink = gitHubURL; From f2ed58f3296ce2917f02ca584e7b83c33a1b741c Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Tue, 4 Jun 2024 17:02:31 +0300 Subject: [PATCH 03/24] repro --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4230a2b198d7..92e8f8c440fd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -81,7 +81,8 @@ body: validations: required: true -- type: textarea +- id: repro + type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). From 9c0ef91fd9e90d29a1b424115c59d785f84da4e7 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Wed, 5 Jun 2024 16:58:31 +0300 Subject: [PATCH 04/24] os version --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 92e8f8c440fd..38a266ff438f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -104,7 +104,8 @@ body: validations: required: false -- type: textarea +- id: othersoftware + type: textarea attributes: label: Other Software description: If you're reporting a bug about our interaction with other software, what software? What versions? From e7cc3a04f7fb0b5b7924ea7d0fb7ee0fc762982b Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Wed, 5 Jun 2024 17:27:18 +0300 Subject: [PATCH 05/24] isadmin --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 38a266ff438f..4c5887644d81 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -33,7 +33,8 @@ body: validations: required: true -- type: dropdown +- id: isadmin + type: dropdown attributes: label: Running as admin description: Are you running PowerToys as Admin? @@ -81,8 +82,7 @@ body: validations: required: true -- id: repro - type: textarea +- type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). From f97cc86f673b3c3738aae9546a4618cc25427505 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Thu, 6 Jun 2024 15:55:47 +0300 Subject: [PATCH 06/24] report --- .github/ISSUE_TEMPLATE/bug_report.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4c5887644d81..bcb15f1e001f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -10,6 +10,16 @@ body: - id: version type: input attributes: + value: | + label: Microsoft PowerToys version placeholder: 0.70.0 description: Hover over system tray icon or look at Settings From c87a344007c10308fe38ee7889c5cf572877265b Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Thu, 6 Jun 2024 15:56:55 +0300 Subject: [PATCH 07/24] report --- .github/ISSUE_TEMPLATE/bug_report.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bcb15f1e001f..e96897117655 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -5,10 +5,6 @@ labels: - Needs-Triage body: - type: markdown - attributes: - value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- id: version - type: input attributes: value: | + value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! +- id: version + type: input + attributes: label: Microsoft PowerToys version placeholder: 0.70.0 description: Hover over system tray icon or look at Settings From 3c6d882e91ec0161ba1f2f62096594a95e87e396 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Thu, 6 Jun 2024 15:58:52 +0300 Subject: [PATCH 08/24] report --- .github/ISSUE_TEMPLATE/bug_report.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e96897117655..4c5887644d81 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,16 +6,6 @@ labels: body: - type: markdown attributes: - value: | - value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! - id: version type: input From c716aa65aee3c532916ea25324e33f5b4c0f7df5 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:51:58 +0300 Subject: [PATCH 09/24] Revert "report" This reverts commit 3c6d882e91ec0161ba1f2f62096594a95e87e396. --- .github/ISSUE_TEMPLATE/bug_report.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4c5887644d81..e96897117655 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,6 +6,16 @@ labels: body: - type: markdown attributes: + value: | + value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! - id: version type: input From 27b234e38ec05fd3f6a7871f630e821830ea839d Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:02 +0300 Subject: [PATCH 10/24] Revert "report" This reverts commit c87a344007c10308fe38ee7889c5cf572877265b. --- .github/ISSUE_TEMPLATE/bug_report.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e96897117655..bcb15f1e001f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -5,6 +5,10 @@ labels: - Needs-Triage body: - type: markdown + attributes: + value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! +- id: version + type: input attributes: value: | - value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- id: version - type: input - attributes: label: Microsoft PowerToys version placeholder: 0.70.0 description: Hover over system tray icon or look at Settings From ce010f5f7af6d8bfd937b55e71a30fb2064ebc66 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:05 +0300 Subject: [PATCH 11/24] Revert "report" This reverts commit f97cc86f673b3c3738aae9546a4618cc25427505. --- .github/ISSUE_TEMPLATE/bug_report.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bcb15f1e001f..4c5887644d81 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -10,16 +10,6 @@ body: - id: version type: input attributes: - value: | - label: Microsoft PowerToys version placeholder: 0.70.0 description: Hover over system tray icon or look at Settings From 51a33afbdbfb3e407833449b75e6ded37ead24a3 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:10 +0300 Subject: [PATCH 12/24] Revert "isadmin" This reverts commit e7cc3a04f7fb0b5b7924ea7d0fb7ee0fc762982b. --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4c5887644d81..38a266ff438f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -33,8 +33,7 @@ body: validations: required: true -- id: isadmin - type: dropdown +- type: dropdown attributes: label: Running as admin description: Are you running PowerToys as Admin? @@ -82,7 +81,8 @@ body: validations: required: true -- type: textarea +- id: repro + type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). From 5596a32e3d4e5090cce95e56cf6a03a126410d5a Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:13 +0300 Subject: [PATCH 13/24] Revert "os version" This reverts commit 9c0ef91fd9e90d29a1b424115c59d785f84da4e7. --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 38a266ff438f..92e8f8c440fd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -104,8 +104,7 @@ body: validations: required: false -- id: othersoftware - type: textarea +- type: textarea attributes: label: Other Software description: If you're reporting a bug about our interaction with other software, what software? What versions? From f9b1588375645cdf686e2e8342014c96b6ef7a64 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:16 +0300 Subject: [PATCH 14/24] Revert "repro" This reverts commit f2ed58f3296ce2917f02ca584e7b83c33a1b741c. --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 92e8f8c440fd..4230a2b198d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -81,8 +81,7 @@ body: validations: required: true -- id: repro - type: textarea +- type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). From 5c0e14656e997f66e4f09cc757b4aaac99636d3e Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:19 +0300 Subject: [PATCH 15/24] Revert "Github URL" This reverts commit 96c09532fadb992dfe20523f8eb28247ab300827. --- src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index a2ce031a7eb1..9079d3c58ee1 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -198,7 +198,7 @@ public void InitializeReportBugLink() { var version = HttpUtility.UrlEncode(GetPowerToysVersion()); - var gitHubURL = "https://github.com/gokcekantarci/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + + var gitHubURL = "https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + "&version=" + version; ReportBugLink = gitHubURL; From d45ae2c1978ef6a614a5bc8ca858f7adbce404b8 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 13:52:24 +0300 Subject: [PATCH 16/24] Revert "Test version" This reverts commit 65a313fb4e4126db0dcedeb967cbc0fca5c696c0. --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +- .../SettingsXAML/Views/GeneralPage.xaml | 2 +- .../SettingsXAML/Views/GeneralPage.xaml.cs | 2 - .../ViewModels/GeneralViewModel.cs | 43 ------------------- 4 files changed, 2 insertions(+), 48 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4230a2b198d7..78affbb16f13 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,8 +7,7 @@ body: - type: markdown attributes: value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- id: version - type: input +- type: input attributes: label: Microsoft PowerToys version placeholder: 0.70.0 diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml index 65a0d12b6b0d..4ffa0bf4a999 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml @@ -367,7 +367,7 @@ - + diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs index c01a1da87c16..ed29e2e9f6d7 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/GeneralPage.xaml.cs @@ -84,8 +84,6 @@ public GeneralPage() DataContext = ViewModel; doRefreshBackupRestoreStatus(100); - - ViewModel.InitializeReportBugLink(); } private void OpenColorsSettings_Click(object sender, RoutedEventArgs e) diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index 9079d3c58ee1..8d55056f64d4 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; @@ -12,8 +11,6 @@ using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading.Tasks; -using System.Web; -using CommunityToolkit.WinUI.Helpers; using global::PowerToys.GPOWrapper; using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; @@ -21,7 +18,6 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; -using Windows.System; namespace Microsoft.PowerToys.Settings.UI.ViewModels { @@ -181,46 +177,7 @@ public GeneralViewModel(ISettingsRepository settingsRepository, private string _settingsBackupMessage; private string _backupRestoreMessageSeverity; - private string reportBugLink; - // Gets or sets a value indicating whether run powertoys on start-up. - public string ReportBugLink - { - get => reportBugLink; - set - { - reportBugLink = value; - OnPropertyChanged(nameof(ReportBugLink)); - } - } - - public void InitializeReportBugLink() - { - var version = HttpUtility.UrlEncode(GetPowerToysVersion()); - - var gitHubURL = "https://github.com/microsoft/PowerToys/issues/new?assignees=&labels=Issue-Bug%2CTriage-Needed&template=bug_report.yml" + - "&version=" + version; - - ReportBugLink = gitHubURL; - } - - private string GetPowerToysVersion() - { - return "0.88.0"; // Replace with the actual method to get the version. - } - - private string GetOSVersion() - { - // Implement a method to get the OS version - return "OS_VERSION_PLACEHOLDER"; - } - - private string GetDotNetVersion() - { - // Implement a method to get the .NET version - return "DOT_NET_VERSION_PLACEHOLDER"; - } - public bool Startup { get From 8cb70648d32b57671ce8a39933f0b7de6b1f535e Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Fri, 7 Jun 2024 15:44:41 +0300 Subject: [PATCH 17/24] Main test bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 78affbb16f13..38a266ff438f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,7 +7,8 @@ body: - type: markdown attributes: value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- type: input +- id: version + type: input attributes: label: Microsoft PowerToys version placeholder: 0.70.0 @@ -80,7 +81,8 @@ body: validations: required: true -- type: textarea +- id: repro + type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). @@ -102,7 +104,8 @@ body: validations: required: false -- type: textarea +- id: othersoftware + type: textarea attributes: label: Other Software description: If you're reporting a bug about our interaction with other software, what software? What versions? From e1fa78c50f242fa7e9d7e93d1585b32d57909ecf Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Mon, 10 Jun 2024 14:22:57 +0300 Subject: [PATCH 18/24] iselevated --- .github/ISSUE_TEMPLATE/bug_report.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 38a266ff438f..691a96f960c5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -33,13 +33,14 @@ body: validations: required: true -- type: dropdown +- id: iselevated + type: input attributes: label: Running as admin description: Are you running PowerToys as Admin? - options: - - "Yes" - - "No" + placeholder: Yes + validations: + required: true - type: dropdown attributes: From e21783473eb7d4eac741b1303297fbd4ceb0f154 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Mon, 10 Jun 2024 14:31:17 +0300 Subject: [PATCH 19/24] iselevated --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 691a96f960c5..ce15616d0d3f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -38,7 +38,7 @@ body: attributes: label: Running as admin description: Are you running PowerToys as Admin? - placeholder: Yes + placeholder: "Yes" validations: required: true From 9324162007b0850af62b003047c664b2489f17fa Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Tue, 9 Jul 2024 15:55:01 +0300 Subject: [PATCH 20/24] [BugReport] bug_report.yml is changed. --- .github/ISSUE_TEMPLATE/bug_report.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ce15616d0d3f..4f74a5af2790 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -33,15 +33,6 @@ body: validations: required: true -- id: iselevated - type: input - attributes: - label: Running as admin - description: Are you running PowerToys as Admin? - placeholder: "Yes" - validations: - required: true - - type: dropdown attributes: label: Area(s) with issue? @@ -104,8 +95,21 @@ body: placeholder: What happened instead? validations: required: false + +- id: additionalInfo + type: textarea + attributes: + label: Additional Information + placeholder: | + OS version + .Net version + Preferred System Language + User or System Installation + Running as admin + validations: + required: false -- id: othersoftware +- id: otherSoftware type: textarea attributes: label: Other Software From 17dc57eeab11545769f3531ec0ba856de164b57e Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Tue, 24 Sep 2024 14:08:15 +0300 Subject: [PATCH 21/24] [KBM] Pressed modifier keys are saved to check before invoking shortcuts --- .../KeyboardEventHandlers.cpp | 147 ++++++++++++++++-- .../KeyboardEventHandlers.h | 6 + .../KeyboardManagerEngineLibrary/State.cpp | 27 ++++ .../KeyboardManagerEngineLibrary/State.h | 14 ++ 4 files changed, 185 insertions(+), 9 deletions(-) diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp index 2bf9d302a79a..8e715cb1fc15 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp @@ -228,6 +228,37 @@ namespace KeyboardEventHandlers for (auto& itShortcut : state.GetSortedShortcutRemapVector(activatedApp)) { const auto it = reMap.find(itShortcut); + static bool isAltRightKeyInvoked = false; + + // Release key and delete from previous modifier key vector + if ((Helpers::IsModifierKey(data->lParam->vkCode) && (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP))) + { + std::vector keyEventList; + if (!(isAltRightKeyInvoked && data->lParam->vkCode == VK_LCONTROL)) + { + Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, static_cast(data->lParam->vkCode), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); + state.ResetPreviousModifierKey(data->lParam->vkCode); + } + + if (isAltRightKeyInvoked && data->lParam->vkCode == VK_RMENU && state.FindPreviousModifierKey(VK_LCONTROL)) + { + Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, static_cast(it->first.GetCtrlKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); + state.ResetPreviousModifierKey(it->first.GetCtrlKey()); + } + + ii.SendVirtualInput(keyEventList); + + } + else if ((Helpers::IsModifierKey(data->lParam->vkCode) && (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN))) + { + // Set the previous modifier key of the invoked shortcut + SetPreviousModifierKey(it, data->lParam->vkCode, state); + // Check if the right Alt key (AltGr) is pressed. + if (data->lParam->vkCode == VK_RMENU && state.FindPreviousModifierKey(VK_LCONTROL)) + { + isAltRightKeyInvoked = true; + } + } // If a shortcut is currently in the invoked state then skip till the shortcut that is currently invoked if (isShortcutInvoked && !it->second.isShortcutInvoked) @@ -235,6 +266,12 @@ namespace KeyboardEventHandlers continue; } + // If action key is pressed check modifier key from shortcut with previous modifier key saved at state + if ((data->lParam->vkCode == it->first.GetActionKey()) && (state.GetPreviousModifierKey().size() == 0 || !CheckPreviousModifierKey(it, state))) + { + continue; + } + // Check if the remap is to a key or a shortcut const bool remapToKey = it->second.targetShortcut.index() == 0; const bool remapToShortcut = it->second.targetShortcut.index() == 1; @@ -247,14 +284,6 @@ namespace KeyboardEventHandlers bool isMatchOnChordEnd = false; bool isMatchOnChordStart = false; - static bool isAltRightKeyInvoked = false; - - // Check if the right Alt key (AltGr) is pressed. - if (data->lParam->vkCode == VK_RMENU && ii.GetVirtualKeyState(VK_LCONTROL)) - { - isAltRightKeyInvoked = true; - } - // If the shortcut has been pressed down if (!it->second.isShortcutInvoked && it->first.CheckModifiersKeyboardState(ii)) { @@ -711,7 +740,7 @@ namespace KeyboardEventHandlers // Send a dummy key event to prevent modifier press+release from being triggered. Example: Win+A->V, press Shift+Win+A and release A, since Win will be pressed here we need to send a dummy event after it Helpers::SetDummyKeyEvent(keyEventList, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); - if (!isAltRightKeyInvoked) + if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode == VK_RMENU)) { // Reset the remap state it->second.isShortcutInvoked = false; @@ -1727,4 +1756,104 @@ namespace KeyboardEventHandlers return 1; } + + bool CheckPreviousModifierKey(const ShortcutRemapTable::iterator it, State& state) + { + auto previousKeys = state.GetPreviousModifierKey(); + if (!previousKeys.empty()) + { + if (it->first.GetShiftKey() != 0) + { + if (!state.FindPreviousModifierKey(it->first.GetShiftKey())) + { + return false; + } + } + else + { + for (auto key : previousKeys) + { + if ((VK_SHIFT == key) || (VK_LSHIFT == key) || (VK_RSHIFT == key)) + { + return false; + } + } + } + + if (it->first.GetAltKey() != 0) + { + if (!state.FindPreviousModifierKey(it->first.GetAltKey())) + { + return false; + } + } + else + { + for (auto key : previousKeys) + { + if ((VK_MENU == key) || (VK_LMENU == key) || (VK_RMENU == key)) + { + return false; + } + } + } + + if (it->first.GetCtrlKey() != 0) + { + if (!state.FindPreviousModifierKey(it->first.GetCtrlKey())) + { + return false; + } + } + else + { + for (auto key : previousKeys) + { + if ((VK_CONTROL == key) || (VK_LCONTROL == key) || (VK_RCONTROL == key)) + { + return false; + } + } + } + + if (it->first.GetWinKey(it->second.winKeyInvoked) != 0) + { + if (!state.FindPreviousModifierKey(it->first.GetWinKey(it->second.winKeyInvoked))) + { + return false; + } + } + else + { + for (auto key : previousKeys) + { + if ((VK_LWIN == key) || (VK_RWIN == key)) + { + return false; + } + } + } + } + return true; + } + + void SetPreviousModifierKey(const ShortcutRemapTable::iterator it, const DWORD key, State& state) + { + if (it->first.GetWinKey(it->second.winKeyInvoked) == key) + { + state.SetPreviousModifierKey(it->first.GetWinKey(it->second.winKeyInvoked)); + } + else if (it->first.GetCtrlKey() == key) + { + state.SetPreviousModifierKey(it->first.GetCtrlKey()); + } + else if (it->first.GetAltKey() == key) + { + state.SetPreviousModifierKey(it->first.GetAltKey()); + } + else if (it->first.GetShiftKey() == key) + { + state.SetPreviousModifierKey(it->first.GetShiftKey()); + } + } } diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.h b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.h index 67eeed69775f..67ca79468fd3 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.h +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.h @@ -84,4 +84,10 @@ namespace KeyboardEventHandlers // Function to ensure Ctrl/Shift/Alt modifier key state is not detected as pressed down by applications which detect keys at a lower level than hooks when it is remapped for scenarios where its required void ResetIfModifierKeyForLowerLevelKeyHandlers(KeyboardManagerInput::InputInterface& ii, DWORD key, DWORD target); + + // Function to check previous modifier key with state + bool CheckPreviousModifierKey(const ShortcutRemapTable::iterator it, State& state); + + // Function to set previous modifier key to state + void SetPreviousModifierKey(const ShortcutRemapTable::iterator it, const DWORD key, State& state); }; diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.cpp index e56b1dc0e6a9..d004d6b163d9 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.cpp @@ -73,3 +73,30 @@ std::wstring State::GetActivatedApp() { return activatedAppSpecificShortcutTarget; } + +// Sets the previous modifier key to check in another shortcut +void State::SetPreviousModifierKey(const DWORD prevKey) +{ + if (!FindPreviousModifierKey(prevKey)) + { + previousModifierKey.emplace_back(prevKey); + } +} + +// Gets the previous modifier key +std::vector State::GetPreviousModifierKey() +{ + return previousModifierKey; +} + +// Check if a key exists in the previousModifierKey vector +bool State::FindPreviousModifierKey(const DWORD prevKey) +{ + return std::find(previousModifierKey.begin(), previousModifierKey.end(), prevKey) != previousModifierKey.end(); +} + +// Resets the previous modifier key +void State::ResetPreviousModifierKey(const DWORD prevKey) +{ + previousModifierKey.erase(std::remove(previousModifierKey.begin(), previousModifierKey.end(), prevKey), previousModifierKey.end()); +} diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.h b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.h index 53b476302ad1..d5b8632f1426 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.h +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/State.h @@ -6,6 +6,8 @@ class State : public MappingConfiguration private: // Stores the activated target application in app-specific shortcut std::wstring activatedAppSpecificShortcutTarget; + // Stores the previous modifier key + std::vector previousModifierKey; public: // Function to get the iterator of a single key remap given the source key. Returns nullopt if it isn't remapped @@ -26,4 +28,16 @@ class State : public MappingConfiguration // Gets the activated target application in app-specific shortcut std::wstring GetActivatedApp(); + + // Sets the previous modifier key to check in another shortcut + void SetPreviousModifierKey(const DWORD prevKey); + + // Gets the previous modifier key + std::vector GetPreviousModifierKey(); + + // Check a key if exist in previous modifier key vector + bool FindPreviousModifierKey(const DWORD prevKey); + + // Resets the previous modifier key + void ResetPreviousModifierKey(const DWORD prevKey); }; \ No newline at end of file From 1157e8c5a613e8a4c3b44c4a082a3a55663339b1 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Wed, 2 Oct 2024 14:09:40 +0300 Subject: [PATCH 22/24] [KBM] Fixed invoking a shortcut and sending text with same modifier keys bug. --- .../KeyboardEventHandlers.cpp | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp index 8e715cb1fc15..17bb97fba369 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp @@ -242,7 +242,7 @@ namespace KeyboardEventHandlers if (isAltRightKeyInvoked && data->lParam->vkCode == VK_RMENU && state.FindPreviousModifierKey(VK_LCONTROL)) { - Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, static_cast(it->first.GetCtrlKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); + Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, VK_LCONTROL, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); state.ResetPreviousModifierKey(it->first.GetCtrlKey()); } @@ -677,22 +677,13 @@ namespace KeyboardEventHandlers if (!remapToText && ((!it->first.HasChord() && data->lParam->vkCode == it->first.GetActionKey()) || (it->first.HasChord() && data->lParam->vkCode == it->first.GetSecondKey())) && (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)) { std::vector keyEventList; - if (remapToShortcut && !it->first.HasChord()) + if (remapToShortcut) { - // Just lift the action key for no chords. + // Just lift the action key. Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, static_cast(std::get(it->second.targetShortcut).GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); - } - else if (remapToShortcut && it->first.HasChord()) - { - // If it has a chord, we'll want a full clean contemplated in the else, since you can't really repeat chords by pressing the end key again. - // Key up for all new shortcut keys, key down for original shortcut modifiers and current key press but common keys aren't repeated - Helpers::SetKeyEvent(keyEventList, INPUT_KEYBOARD, static_cast(std::get(it->second.targetShortcut).GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); - - // Release new shortcut state (release in reverse order of shortcut to be accurate) Helpers::SetModifierKeyEvents(std::get(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first); - // Set old shortcut key down state Helpers::SetModifierKeyEvents(it->first, it->second.winKeyInvoked, keyEventList, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, std::get(it->second.targetShortcut)); // Reset the remap state @@ -740,7 +731,7 @@ namespace KeyboardEventHandlers // Send a dummy key event to prevent modifier press+release from being triggered. Example: Win+A->V, press Shift+Win+A and release A, since Win will be pressed here we need to send a dummy event after it Helpers::SetDummyKeyEvent(keyEventList, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); - if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode == VK_RMENU)) + if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode != VK_LCONTROL)) { // Reset the remap state it->second.isShortcutInvoked = false; @@ -877,7 +868,7 @@ namespace KeyboardEventHandlers // Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after shortcut to shortcut is released to open start menu } - if (!isAltRightKeyInvoked) + if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode != VK_LCONTROL)) { // Reset the remap state it->second.isShortcutInvoked = false; @@ -928,7 +919,7 @@ namespace KeyboardEventHandlers { std::vector keyEventList; - if (!isAltRightKeyInvoked) + if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode != VK_LCONTROL)) { // Set original shortcut key down state Helpers::SetModifierKeyEvents(it->first, it->second.winKeyInvoked, keyEventList, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG); @@ -946,7 +937,7 @@ namespace KeyboardEventHandlers // Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after another shortcut to key remap is released to open start menu - if (!isAltRightKeyInvoked) + if (!isAltRightKeyInvoked || (isAltRightKeyInvoked && data->lParam->vkCode != VK_LCONTROL)) { // Reset the remap state it->second.isShortcutInvoked = false; From d172fe94a0c0b626f35fccb202affafb49718c78 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Wed, 2 Oct 2024 15:17:54 +0300 Subject: [PATCH 23/24] [KBM] Remove unnecessary code. --- .github/ISSUE_TEMPLATE/bug_report.yml | 31 +++++++++++---------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d27cc392a9fa..56800fb1d6b8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,8 +7,7 @@ body: - type: markdown attributes: value: Please make sure to [search for existing issues](https://github.com/microsoft/PowerToys/issues) before filing a new one! -- id: version - type: input +- type: input attributes: label: Microsoft PowerToys version placeholder: 0.70.0 @@ -33,6 +32,14 @@ body: validations: required: true +- type: dropdown + attributes: + label: Running as admin + description: Are you running PowerToys as Admin? + options: + - "Yes" + - "No" + - type: dropdown attributes: label: Area(s) with issue? @@ -58,6 +65,7 @@ body: - Keyboard Manager - Mouse Utilities - Mouse Without Borders + - New+ - Peek - PowerRename - PowerToys Run @@ -74,8 +82,7 @@ body: validations: required: true -- id: repro - type: textarea +- type: textarea attributes: label: Steps to reproduce description: We highly suggest including screenshots and a bug report log (System tray > Report bug). @@ -96,22 +103,8 @@ body: placeholder: What happened instead? validations: required: false - -- id: additionalInfo - type: textarea - attributes: - label: Additional Information - placeholder: | - OS version - .Net version - Preferred System Language - User or System Installation - Running as admin - validations: - required: false -- id: otherSoftware - type: textarea +- type: textarea attributes: label: Other Software description: If you're reporting a bug about our interaction with other software, what software? What versions? From cd142d2d06b50393bf87035fae062e11ba52e4d3 Mon Sep 17 00:00:00 2001 From: Gokce Kantarci Date: Wed, 2 Oct 2024 17:46:36 +0300 Subject: [PATCH 24/24] [KBM] Unit fix. Set winKeyInvoked before SetPreviousModifierKey and reset after ResetPreviousModifierKey. --- .../KeyboardEventHandlers.cpp | 27 +++++++++++-------- .../OSLevelShortcutRemappingTests.cpp | 8 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp index 17bb97fba369..04bb461a5eeb 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardEventHandlers.cpp @@ -228,7 +228,7 @@ namespace KeyboardEventHandlers for (auto& itShortcut : state.GetSortedShortcutRemapVector(activatedApp)) { const auto it = reMap.find(itShortcut); - static bool isAltRightKeyInvoked = false; + static bool isAltRightKeyInvoked = false; // Release key and delete from previous modifier key vector if ((Helpers::IsModifierKey(data->lParam->vkCode) && (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP))) @@ -246,11 +246,26 @@ namespace KeyboardEventHandlers state.ResetPreviousModifierKey(it->first.GetCtrlKey()); } + if (data->lParam->vkCode == VK_RWIN || data->lParam->vkCode == VK_LWIN) + { + it->second.winKeyInvoked = ModifierKey::Disabled; + } + ii.SendVirtualInput(keyEventList); } else if ((Helpers::IsModifierKey(data->lParam->vkCode) && (data->wParam == WM_KEYDOWN || data->wParam == WM_SYSKEYDOWN))) { + // Remember which win key was pressed initially + if (data->lParam->vkCode == VK_RWIN) + { + it->second.winKeyInvoked = ModifierKey::Right; + } + else if (data->lParam->vkCode == VK_LWIN) + { + it->second.winKeyInvoked = ModifierKey::Left; + } + // Set the previous modifier key of the invoked shortcut SetPreviousModifierKey(it, data->lParam->vkCode, state); // Check if the right Alt key (AltGr) is pressed. @@ -339,16 +354,6 @@ namespace KeyboardEventHandlers std::vector keyEventList; - // Remember which win key was pressed initially - if (ii.GetVirtualKeyState(VK_RWIN)) - { - it->second.winKeyInvoked = ModifierKey::Right; - } - else if (ii.GetVirtualKeyState(VK_LWIN)) - { - it->second.winKeyInvoked = ModifierKey::Left; - } - if (isRunProgram) { auto threadFunction = [it]() { diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineTest/OSLevelShortcutRemappingTests.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineTest/OSLevelShortcutRemappingTests.cpp index 4b470ec5a6e0..33c17b6af327 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineTest/OSLevelShortcutRemappingTests.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineTest/OSLevelShortcutRemappingTests.cpp @@ -861,7 +861,7 @@ namespace RemappingLogicTests Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(0x56), false); } - // Test if target modifier is still held down even if the action key of the original shortcut is released - required for Alt+Tab/Win+Space cases + // Test if original modifier is still held down even if the action key of the original shortcut is released - required for Alt+Tab/Win+Space cases TEST_METHOD (RemappedShortcutModifiers_ShouldBeDetectedAsPressed_OnReleasingActionKeyButHoldingModifiers) { // Remap Ctrl+A to Alt+Tab @@ -882,10 +882,10 @@ namespace RemappingLogicTests // Send Ctrl+A, release A mockedInputHandler.SendVirtualInput(inputs); - // Ctrl, A, Tab key states should be unchanged, Alt should be true - Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(VK_CONTROL), false); + // Alt, A, Tab key states should be unchanged, Ctrl should be true + Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(VK_CONTROL), true); Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(0x41), false); - Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(VK_MENU), true); + Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(VK_MENU), false); Assert::AreEqual(mockedInputHandler.GetVirtualKeyState(VK_TAB), false); }