Compare commits

..

5 Commits

Author SHA1 Message Date
Jaime Bernardo
5974aae7e3 [NewPlus]Normalize settings infrastructure 2024-09-30 15:18:02 +01:00
Stefan Markovic
9b41786c57 [Deps]Revert CommunityToolkit update to fix ARM settings app crash (#35139) 2024-09-30 15:00:50 +01:00
Laszlo Nemeth
d527d9576d [Workspaces]Fix snapshot tool: update capturing windows settings app (#35140)
* [Workspaces] fix snapshot tool: update capturing windows settings app

* spell checker

* spell checker

* minor change in app utils, when the system settings app is captured
2024-09-30 14:37:21 +01:00
Seraphima Zykova
6bab73777b [Workspaces]Fix Steam repositioning (#35101)
* moved and simplified logic

* address PR comment
2024-09-27 23:00:53 +01:00
Den Delimarsky
ff17e3dec9 [Awake]Log error with Logger instead of console (#35100) 2024-09-27 20:38:42 +01:00
18 changed files with 271 additions and 313 deletions

View File

@@ -1590,7 +1590,7 @@ SYSKEYUP
SYSLIB
SYSMENU
SYSTEMAPPS
systemsettings
SYSTEMSETTINGS
SYSTEMTIME
SYSTEMWOW
tapp

View File

@@ -32,7 +32,7 @@ parameters:
- name: enableMsBuildCaching
type: boolean
displayName: "Enable MSBuild Caching"
default: true
default: false
- name: runTests
type: boolean
displayName: "Run Tests"

View File

@@ -6,14 +6,14 @@
<PackageVersion Include="Appium.WebDriver" Version="4.4.5" />
<PackageVersion Include="Azure.AI.OpenAI" Version="1.0.0-beta.12" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Collections" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.1.240821" />
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Collections" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.0.240109" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
<PackageVersion Include="ControlzEx" Version="6.0.0" />

View File

@@ -1299,14 +1299,14 @@ EXHIBIT A -Mozilla Public License.
- Appium.WebDriver 4.4.5
- Azure.AI.OpenAI 1.0.0-beta.12
- CommunityToolkit.Mvvm 8.2.2
- CommunityToolkit.WinUI.Animations 8.1.240821
- CommunityToolkit.WinUI.Collections 8.1.240821
- CommunityToolkit.WinUI.Controls.Primitives 8.1.240821
- CommunityToolkit.WinUI.Controls.Segmented 8.1.240821
- CommunityToolkit.WinUI.Controls.SettingsControls 8.1.240821
- CommunityToolkit.WinUI.Controls.Sizers 8.1.240821
- CommunityToolkit.WinUI.Converters 8.1.240821
- CommunityToolkit.WinUI.Extensions 8.1.240821
- CommunityToolkit.WinUI.Animations 8.0.240109
- CommunityToolkit.WinUI.Collections 8.0.240109
- CommunityToolkit.WinUI.Controls.Primitives 8.0.240109
- CommunityToolkit.WinUI.Controls.Segmented 8.0.240109
- CommunityToolkit.WinUI.Controls.SettingsControls 8.0.240109
- CommunityToolkit.WinUI.Controls.Sizers 8.0.240109
- CommunityToolkit.WinUI.Converters 8.0.240109
- CommunityToolkit.WinUI.Extensions 8.0.240109
- CommunityToolkit.WinUI.UI.Controls.DataGrid 7.1.2
- CommunityToolkit.WinUI.UI.Controls.Markdown 7.1.2
- ControlzEx 6.0.0

150
README.md
View File

@@ -22,10 +22,10 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
| [Environment Variables](https://aka.ms/PowerToysOverview_EnvironmentVariables) | [FancyZones](https://aka.ms/PowerToysOverview_FancyZones) | [File Explorer Add-ons](https://aka.ms/PowerToysOverview_FileExplorerAddOns) |
| [File Locksmith](https://aka.ms/PowerToysOverview_FileLocksmith) | [Hosts File Editor](https://aka.ms/PowerToysOverview_HostsFileEditor) | [Image Resizer](https://aka.ms/PowerToysOverview_ImageResizer) |
| [Keyboard Manager](https://aka.ms/PowerToysOverview_KeyboardManager) | [Mouse utilities](https://aka.ms/PowerToysOverview_MouseUtilities) | [Mouse Without Borders](https://aka.ms/PowerToysOverview_MouseWithoutBorders) |
| [New+](https://aka.ms/PowerToysOverview_NewPlus) | [Peek](https://aka.ms/PowerToysOverview_Peek) | [Paste as Plain Text](https://aka.ms/PowerToysOverview_PastePlain) |
| [PowerRename](https://aka.ms/PowerToysOverview_PowerRename) | [PowerToys Run](https://aka.ms/PowerToysOverview_PowerToysRun) | [Quick Accent](https://aka.ms/PowerToysOverview_QuickAccent) |
| [Registry Preview](https://aka.ms/PowerToysOverview_RegistryPreview) | [Screen Ruler](https://aka.ms/PowerToysOverview_ScreenRuler) | [Shortcut Guide](https://aka.ms/PowerToysOverview_ShortcutGuide) |
| [Text Extractor](https://aka.ms/PowerToysOverview_TextExtractor) | [Video Conference Mute](https://aka.ms/PowerToysOverview_VideoConference) | [Workspaces](https://aka.ms/PowerToysOverview_Workspaces) |
| [Peek](https://aka.ms/PowerToysOverview_Peek) | [Paste as Plain Text](https://aka.ms/PowerToysOverview_PastePlain) | [PowerRename](https://aka.ms/PowerToysOverview_PowerRename) |
| [PowerToys Run](https://aka.ms/PowerToysOverview_PowerToysRun) | [Quick Accent](https://aka.ms/PowerToysOverview_QuickAccent) | [Registry Preview](https://aka.ms/PowerToysOverview_RegistryPreview) |
| [Screen Ruler](https://aka.ms/PowerToysOverview_ScreenRuler) | [Shortcut Guide](https://aka.ms/PowerToysOverview_ShortcutGuide) | [Text Extractor](https://aka.ms/PowerToysOverview_TextExtractor) |
| [Video Conference Mute](https://aka.ms/PowerToysOverview_VideoConference) | [Workspaces](https://aka.ms/PowerToysOverview_Workspaces) |
## Installing and running Microsoft PowerToys
@@ -41,19 +41,19 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and click on `Assets` at the bottom to show the files available in the release. Please use the appropriate PowerToys installer that matches your machine's architecture and install scope. For most, it is `x64` and per-user.
<!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.86%22
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.85%22
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.85.0/PowerToysUserSetup-0.85.0-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.85.0/PowerToysUserSetup-0.85.0-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.85.0/PowerToysSetup-0.85.0-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.85.0/PowerToysSetup-0.85.0-arm64.exe
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.85%22
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.84%22
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.84.1/PowerToysUserSetup-0.84.1-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.84.1/PowerToysUserSetup-0.84.1-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.84.1/PowerToysSetup-0.84.1-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.84.1/PowerToysSetup-0.84.1-arm64.exe
| Description | Filename | sha256 hash |
|----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.85.0-x64.exe][ptUserX64] | 28A8BEA61040751287FF47C9BAC627A53A4670CFEA0C17B96EE947219E9A6EA9 |
| Per user - ARM64 | [PowerToysUserSetup-0.85.0-arm64.exe][ptUserArm64] | 2CA077E842B7C53BAFC75A25DBD16C1A4FCE20924C36FDA5AD8CF23CD836B855 |
| Machine wide - x64 | [PowerToysSetup-0.85.0-x64.exe][ptMachineX64] | 4A248AA914EEE339AA99D467FDFBDB1FCD7A49A8564DDBBB811D0EC69CEBAB75 |
| Machine wide - ARM64 | [PowerToysSetup-0.85.0-arm64.exe][ptMachineArm64] | B5FB04EAF44C4203E785411FF55025842B9C39D4970C0C934CB8ADBE79EF31AF |
| Per user - x64 | [PowerToysUserSetup-0.84.1-x64.exe][ptUserX64] | 1CDAF3482B031D84DAE15188DE292FB44C5D211698089921040D94B256EBD3CA |
| Per user - ARM64 | [PowerToysUserSetup-0.84.1-arm64.exe][ptUserArm64] | E0207EF5147EE281D4F438E87A30586D8CAA24DE948950FF1B12E05454622CD9 |
| Machine wide - x64 | [PowerToysSetup-0.84.1-x64.exe][ptMachineX64] | 10DF9774DE1857051E135B9790A18A92C5C7F42587C733DEE991186E67231EE0 |
| Machine wide - ARM64 | [PowerToysSetup-0.84.1-arm64.exe][ptMachineArm64] | EB5DDA5EFBA17E813DBF24AFF668DDF5424ED3659234ABBC15441D478D812699 |
This is our preferred method.
@@ -99,117 +99,99 @@ For guidance on developing for PowerToys, please read the [developer docs](/doc/
Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on.
### 0.85 - September 2024 Update
### 0.84 - August 2024 Update
In this release, we focused on new features, stability, and improvements.
In this release, we focused on adding a new utility (PowerToys Workspaces), Advanced paste custom actions feature, stability, and improvements.
**Highlights**
- New utility: New+ - allows setting a personalized set of templates to quickly create files and folders from a File Explorer context menu. Thanks [@cgaarden](https://github.com/cgaarden)!
- Language selection - it's now possible to select which UI language should be used by PowerToys utilities.
- Lots of quality fixes for Workspaces, improving the number of supported applications.
- Reduced Peek memory usage by fixing image leaks. Thanks [@daverayment](https://github.com/daverayment)!
- New utility: PowerToys Workspaces - this utility can launch a set of applications to a custom layout and configuration on the desktop. App arrangements can be saved as a workspace and then relaunched with one click from the Workspaces Editor or from a desktop shortcut. In the editor, app configuration can be customized using CLI arguments and "launch as admin" modifiers, and app window sizes and positions can be updated as desired. This is our first public version of Workspaces and we are excited for you to try it out for yourself! Make sure to file issues you encounter on our GitHub so the team can continue to improve the utility.
- Known issues - the team is actively working on fixing these:
- Apps that launch as admin are unable to be repositioned to the desired layout.
- Border of "Remove" / "Add Back" app button in editor is not clearly visible on light themes.
- Added Awake --use-parent-pid CLI argument to attach to parent process. Thanks [@dend](https://github.com/dend)!
- Added custom actions - user-specified pre-defined prompts for the AI model. Additionally, actions (both standard and custom) are now searchable from prompt box and Ctrl + number in-app shortcuts are now applicable for first 9 search results.
- Ported all C++/CX code to C++/WinRT as part of a refactor and upgrade series aimed at enabling AOT (Ahead of Time) compilation for enhanced performance and reduced disk footprint.
### General
- Added a general setting to select which UI language should be used in PowerToys utilities.
- Fixed internal code of some policies for Group Policy Objects, that were reading registry entries using the wrong internal functions, and structured code better to avoid future mistakes of the same kind. Thanks [@htcfreek](https://github.com/htcfreek)!
- Added DSC support for ImageResizer resize sizes property.
### Advanced Paste
- Fixed some telemetry calls to signal Advanced Paste activation on the cases where a direct shortcut is being used without showing the UI.
- User-defined custom actions can only be used with AI turned on, so custom actions were disabled on Settings when AI is disabled and were hidden from the Advanced Paste UI.
- Added custom actions - user-specified pre-defined prompts for the AI model. Additionally, actions (both standard and custom) are now searchable from prompt box and Ctrl + number in-app shortcuts are now applicable for first 9 search results.
### Awake
- Fixed tray icon behaviors, not appearing and showing incorrect time. Thanks [@dend](https://github.com/dend)!
- Added --use-parent-pid CLI argument to attach to parent process and fixed issue causing tray icon to disappear. Thanks [@dend](https://github.com/dend)!
### Environment Variables Editor
### Hosts File Editor
- Added the `_NT_SYMBOL_PATH`, `_NT_ALT_SYMBOL_PATH` and `_NT_SYMCACHE_PATH` as variables that are shown as lists. Thanks [@chwarr](https://github.com/chwarr)!
- Fixed save failure when the hosts file is hidden. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### FancyZones
### File Explorer add-ons
- Allow snapping applications that were launched by Workspaces.
- Fixed multiple preview form positioning issues causing floating, detached windows, CoreWebView2 related exception and process leak. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### File Locksmith
### Keyboard Manager
- Fixed an issue causing File Locksmith to be triggered by unrelated verbs in the context menu.
### Mouse Pointer Crosshairs
- Allow crosshairs radius to be 0 pixels. Thanks [@octastylos-pseudodipteros](https://github.com/octastylos-pseudodipteros)!
### New+
- New utility - Allows setting a personalized set of templates to quickly create files and folders from a File Explorer context menu. Thanks [@cgaarden](https://github.com/cgaarden)!
- Added missing entry for New+ policy state reporting in the Bug Report tool. Thanks [@htcfreek](https://github.com/htcfreek)!
- Added a policy for enabling/disabling whether filename extensions should be shown. Thanks [@htcfreek](https://github.com/htcfreek)!
- Convert RemapBufferRow to a struct with descriptive field names. Thanks [@masaru-iritani](https://github.com/masaru-iritani)!
- Fixed issue causing stuck Ctrl key when shortcuts contain AltGr key.
### Peek
- Properly show file's modified date instead of creation date in the file previewer. Thanks [@daverayment](https://github.com/daverayment)!
- Fixed memory leak caused by unmanaged bitmap images not being freed. Thanks [@daverayment](https://github.com/daverayment)!
- Fixed an issue causing Peek to not be displayed the first time when using a preview handler to display files. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Prevent tooltip in file previewer from overlapping with title bar controls. Thanks [@daverayment](https://github.com/daverayment)!
- Fixed memory leaks in thumbnails and refactored image previewer. Thanks [@daverayment](https://github.com/daverayment)!
### PowerToys Run
- Improved the message boxes to be more specific when PowerToys Run failed to initialize itself or any plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Use capital letters when showing degree results in the Unit Converter plugin. Thanks [@PesBandi](https://github.com/PesBandi)!
- Added long paths support. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Quick Accent
- Add the Middle Eastern Romanization character set. Thanks [@PesBandi](https://github.com/PesBandi)!
- Add the degree sign, integral and vertical ellipsis when "All Languages" is selected. Thanks [@rddunphy](https://github.com/rddunphy)!
- Moved number superscripts and subscripts from Portuguese to all languages definition. Thanks [@octastylos-pseudodipteros](https://github.com/octastylos-pseudodipteros)!
### PowerRename
- Updated the tooltip text of the replace box info button. Thanks [@Agnibaan](https://github.com/Agnibaan)!
### PowerToys Run
- Fixed window positioning on start-up introduced in 0.83.
- Improved default web browser detection. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed volume ounces conversion to support both imperial and metric. Thanks [@GhostVaibhav](https://github.com/GhostVaibhav)!
- Fixed thread-safety issue causing results not to be shown on first launch.
### Screen Ruler
- Added multiple measurements support for all measuring tools.
### Settings
- Fixed the link to the Workspaces documentation. (This was a hotfix for 0.84)
- Fixed flyout issues after the Windows App SDK upgrade. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Fixed initialization for the New+ settings page. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed enabled state of a control on the New+ settings page if the module is enabled by policy. Thanks [@htcfreek](https://github.com/htcfreek)!
- Fixed a crash when cancelling the template folder selection in the New+ settings page.
- Improved disabled animations InfoBar in Find My Mouse page. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
### Workspaces
- Fixed detecting and snapping applications like Discord. (This was a hotfix for 0.84)
- Fixed detecting and snapping applications like Steam. (This was a hotfix for 0.84)
- Fixed button visibility in the UI. (This was a hotfix for 0.84)
- Fixed an issue launching the wrong project when the editor was closed without saving or cancelling a new project.
- Properly handle repositioning windows running as administrator.
- Properly handle cases where the monitor where a workspace was saved is no longer present.
- Fixed the workspace launcher restarting itself in a loop without success.
- Properly handle standalone applications.
- Fixed issues causing icons to not show.
- New utility: PowerToys Workspaces - this utility can launch a set of applications to a custom layout and configuration on the desktop. App arrangements can be saved as a workspace and then relaunched with one click from the Workspaces Editor or from a desktop shortcut. In the editor, app configuration can be customized using CLI arguments and "launch as admin" modifiers, and app window sizes and positions can be updated as desired. This is our first public version of Workspaces and we are excited for you to try it out for yourself! Make sure to file issues you encounter on our GitHub so the team can continue to improve the utility.
### Documentation
- Fixed the thirdPartyRunPlugins.md entry for the RDP plugin. Thanks [@YisroelTech](https://github.com/YisroelTech)!
- Added ChatGPTPowerToys plugin mention to thirdPartyRunPlugins.md. Thanks [@ferraridavide](https://github.com/ferraridavide)!
### Development
- Upgraded Windows App SDK to 1.6.
- Upgraded the Target Platform Version to 10.0.22621.0.
- Added a bot trigger to automatically add a label to Workspaces issues. Thanks [@plante-msft](https://github.com/plante-msft)!
- Fixed a regular expression in the bot triggers for wanting to submit community contributions. Thanks [@PesBandi](https://github.com/PesBandi)!
- Fixed analyzer errors after the Visual Studio 17.12 update. Thanks [@snickler](https://github.com/snickler)!
- Fixed the TSA configuration for release CI builds.
- Refactored automated file component generation during installer builds.
- Rewrote the Azure Devops build system to be more modular and share more definitions between PR CI and Release CI.
- Fixed debugging of the New+ page of the Settings application when a settings file was not present.
- Fixed setting the version of the App Manifest in the File Locksmith and New+ context menu app packages.
- Fixed abstracted UI library nuget package signing on release CI.
- Removed build status from GitHub README.
- Ported all C++/CX code to C++/WinRT.
- Moved Version.props import to Directory.Build.props.
- Extracted self-containment related .csproj properties to src/Common.SelfContained.props.
- Unused and obsolete dependencies cleanup. Thanks [@davidegiacometti](https://github.com/davidegiacometti)!
- Extracted CSWinRT related .csproj properties to src/Common.Dotnet.CsWinRT.props.
- Upgraded Microsoft.Windows.CsWinRT to 2.0.8 and updated verifyDepsJsonLibraryVersions.ps1 to unblock PRs.
- Explicitly Set NuGet Audit Mode to Direct in Directory.Build.props to revert changes made with VS 17.12 update. Thanks [@snickler](https://github.com/snickler)!
- Upgraded UnitsNet to 5.56.0.
#### What is being planned for version 0.86
#### What is being planned for version 0.84
For [v0.86][github-next-release-work], we'll work on the items below:
For [v0.85][github-next-release-work], we'll work on the items below:
- Stability / bug fixes
- Language selection
- New module: File Actions Menu
- Integrate Sysinternals ZoomIt
- New module: New+
## PowerToys Community

View File

@@ -51,21 +51,30 @@ public:
return true;
}
virtual void set_config(PCWSTR config) override
virtual void set_config(const wchar_t* config) override
{
// The following just checks to see if the Template Location was changed for metrics purposes
// Note: We are not saving the settings here and instead relying on read/write of json in Settings App .cs code paths
try
{
json::JsonObject config_as_json = json::JsonValue::Parse(winrt::to_hstring(config)).GetObjectW();
// Parse the input JSON string.
PowerToysSettings::PowerToyValues values =
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
const auto latest_location_value = config_as_json.GetNamedString(newplus::constants::non_localizable::settings_json_key_template_location).data();
const auto existing_location_value = NewSettingsInstance().GetTemplateLocation();
values.save_to_settings_file();
NewSettingsInstance().Load();
if (!newplus::utilities::wstring_same_when_comparing_ignore_case(latest_location_value, existing_location_value))
auto templateValue = values.get_string_value(newplus::constants::non_localizable::settings_json_key_template_location);
if (templateValue.has_value())
{
Trace::EventChangedTemplateLocation();
const auto latest_location_value = templateValue.value();
const auto existing_location_value = NewSettingsInstance().GetTemplateLocation();
if (!newplus::utilities::wstring_same_when_comparing_ignore_case(latest_location_value, existing_location_value))
{
Trace::EventChangedTemplateLocation();
}
}
}
catch (std::exception& e)
{

View File

@@ -3,6 +3,7 @@
#include <common/utils/gpo.h>
#include <common/utils/json.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/SettingsAPI/settings_objects.h>
#include "settings.h"
#include "constants.h"
@@ -38,18 +39,13 @@ NewSettings::NewSettings()
void NewSettings::Save()
{
json::JsonObject new_settings_json_data;
PowerToysSettings::PowerToyValues values(newplus::constants::non_localizable::powertoy_key, newplus::constants::non_localizable::powertoy_key);
new_settings_json_data.SetNamedValue(newplus::constants::non_localizable::settings_json_key_hide_file_extension,
json::value(new_settings.hide_file_extension));
values.add_property(newplus::constants::non_localizable::settings_json_key_hide_file_extension, new_settings.hide_file_extension);
values.add_property(newplus::constants::non_localizable::settings_json_key_hide_starting_digits, new_settings.hide_starting_digits);
values.add_property(newplus::constants::non_localizable::settings_json_key_template_location, new_settings.template_location);
new_settings_json_data.SetNamedValue(newplus::constants::non_localizable::settings_json_key_hide_starting_digits,
json::value(new_settings.hide_starting_digits));
new_settings_json_data.SetNamedValue(newplus::constants::non_localizable::settings_json_key_template_location,
json::value(new_settings.template_location));
json::to_file(new_settings_json_file_path, new_settings_json_data);
values.save_to_settings_file();
GetSystemTimeAsFileTime(&new_settings_last_loaded_timestamp);
}
@@ -122,35 +118,27 @@ void NewSettings::Reload()
void NewSettings::ParseJson()
{
auto json = json::from_file(new_settings_json_file_path);
if (json)
PowerToysSettings::PowerToyValues settings =
PowerToysSettings::PowerToyValues::load_from_settings_file(newplus::constants::non_localizable::powertoy_key);
auto templateValue = settings.get_string_value(newplus::constants::non_localizable::settings_json_key_template_location);
if (templateValue.has_value())
{
try
{
const json::JsonObject& new_settings_json = json.value();
if (json::has(new_settings_json, newplus::constants::non_localizable::settings_json_key_hide_file_extension, json::JsonValueType::Boolean))
{
new_settings.hide_file_extension = new_settings_json.GetNamedBoolean(
newplus::constants::non_localizable::settings_json_key_hide_file_extension);
}
if (json::has(new_settings_json, newplus::constants::non_localizable::settings_json_key_hide_starting_digits, json::JsonValueType::Boolean))
{
new_settings.hide_starting_digits = new_settings_json.GetNamedBoolean(
newplus::constants::non_localizable::settings_json_key_hide_starting_digits);
}
if (json::has(new_settings_json, newplus::constants::non_localizable::settings_json_key_template_location, json::JsonValueType::String))
{
new_settings.template_location = new_settings_json.GetNamedString(
newplus::constants::non_localizable::settings_json_key_template_location);
}
}
catch (const winrt::hresult_error&)
{
}
new_settings.template_location = templateValue.value();
}
auto hideFileExtensionValue = settings.get_bool_value(newplus::constants::non_localizable::settings_json_key_hide_file_extension);
if (hideFileExtensionValue.has_value())
{
new_settings.hide_file_extension = hideFileExtensionValue.value();
}
auto hideStartingDigitsValue = settings.get_bool_value(newplus::constants::non_localizable::settings_json_key_hide_starting_digits);
if (hideStartingDigitsValue.has_value())
{
new_settings.hide_starting_digits = hideStartingDigitsValue.value();
}
GetSystemTimeAsFileTime(&new_settings_last_loaded_timestamp);
}

View File

@@ -2,8 +2,9 @@
#include "AppUtils.h"
#include <atlbase.h>
#include <ShlObj.h>
#include <propvarutil.h>
#include <ShlObj.h>
#include <TlHelp32.h>
#include <filesystem>
@@ -25,9 +26,11 @@ namespace Utils
constexpr const wchar_t* FileExplorerName = L"File Explorer";
constexpr const wchar_t* FileExplorerPath = L"C:\\WINDOWS\\EXPLORER.EXE";
constexpr const wchar_t* SystemSettingsPath = L"SYSTEMSETTINGS.EXE";
constexpr const wchar_t* PowerToys = L"PowerToys.exe";
constexpr const wchar_t* PowerToysSettingsUpper = L"POWERTOYS.SETTINGS.EXE";
constexpr const wchar_t* PowerToysSettings = L"PowerToys.Settings.exe";
constexpr const wchar_t* ApplicationFrameHost = L"APPLICATIONFRAMEHOST.EXE";
}
AppList IterateAppsFolder()
@@ -184,11 +187,39 @@ namespace Utils
return IterateAppsFolder();
}
std::optional<AppData> GetApp(const std::wstring& appPath, const AppList& apps)
DWORD GetParentPid(DWORD pid)
{
DWORD res = 0;
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = { 0 };
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(h, &pe))
{
do
{
if (pe.th32ProcessID == pid)
{
res = pe.th32ParentProcessID;
}
} while (Process32Next(h, &pe));
}
CloseHandle(h);
return res;
}
std::optional<AppData> GetApp(const std::wstring& appPath, DWORD pid, const AppList& apps)
{
std::wstring appPathUpper(appPath);
std::transform(appPathUpper.begin(), appPathUpper.end(), appPathUpper.begin(), towupper);
// filter out ApplicationFrameHost.exe
if (appPathUpper.ends_with(NonLocalizable::ApplicationFrameHost))
{
return std::nullopt;
}
// edge case, "Windows Software Development Kit" has the same app path as "File Explorer"
if (appPathUpper == NonLocalizable::FileExplorerPath)
{
@@ -217,6 +248,7 @@ namespace Utils
}
}
// search in apps list
for (const auto& appData : apps)
{
if (!appData.installPath.empty())
@@ -226,6 +258,14 @@ namespace Utils
if (appPathUpper.contains(installPathUpper))
{
// check if the found app is the System Settings. If yes, update the install path to the exe path
if (appPathUpper.ends_with(NonLocalizable::SystemSettingsPath))
{
auto settingsAppData = appData;
settingsAppData.installPath = appPath;
return settingsAppData;
}
return appData;
}
@@ -251,11 +291,43 @@ namespace Utils
if (appNameUpper == exeNameUpper)
{
return appData;
auto result = appData;
result.installPath = appPath;
return result;
}
}
// try with parent process (fix for Steam)
auto parentPid = GetParentPid(pid);
auto parentProcessPath = get_process_path(parentPid);
if (!parentProcessPath.empty())
{
std::wstring parentDirUpper = std::filesystem::path(parentProcessPath).parent_path().c_str();
std::transform(parentDirUpper.begin(), parentDirUpper.end(), parentDirUpper.begin(), towupper);
if (appPathUpper.starts_with(parentDirUpper))
{
Logger::info(L"original process is in the subfolder of the parent process");
for (const auto& appData : apps)
{
if (!appData.installPath.empty())
{
std::wstring installDirUpper = std::filesystem::path(appData.installPath).parent_path().c_str();
std::transform(installDirUpper.begin(), installDirUpper.end(), installDirUpper.begin(), towupper);
if (installDirUpper == parentDirUpper)
{
return appData;
}
}
}
}
}
return AppData{
.name = std::filesystem::path(appPath).stem(),
.installPath = appPath
};
}
@@ -263,7 +335,11 @@ namespace Utils
std::optional<AppData> GetApp(HWND window, const AppList& apps)
{
std::wstring processPath = get_process_path(window);
return Utils::Apps::GetApp(processPath, apps);
DWORD pid{};
GetWindowThreadProcessId(window, &pid);
return Utils::Apps::GetApp(processPath, pid, apps);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Utils
const std::wstring& GetCurrentFolderUpper();
AppList GetAppsList();
std::optional<AppData> GetApp(const std::wstring& appPath, const AppList& apps);
std::optional<AppData> GetApp(const std::wstring& appPath, DWORD pid, const AppList& apps);
std::optional<AppData> GetApp(HWND window, const AppList& apps);
}
}

View File

@@ -12,22 +12,12 @@
#include <workspaces-common/WindowFilter.h>
#include <WorkspacesLib/AppUtils.h>
#include <TlHelp32.h>
namespace SnapshotUtils
{
namespace NonLocalizable
{
const std::wstring ApplicationFrameHost = L"ApplicationFrameHost.exe";
namespace FileManagers
{
const std::wstring FileExplorer = L"EXPLORER"; // windows explorer
const std::wstring TotalCommander = L"TOTALCMD"; // total commander
const std::wstring DirectoryOpus = L"DOPUS"; // directory opus
const std::wstring QDir = L"Q-DIR"; // Q-Dir
const std::wstring Xplorer2 = L"XPLORER2"; // Xplorer2
}
}
class WbemHelper
@@ -178,39 +168,6 @@ namespace SnapshotUtils
return false;
}
DWORD GetParentPid(DWORD pid)
{
DWORD res = 0;
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = { 0 };
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(h, &pe))
{
do
{
if (pe.th32ProcessID == pid)
{
res = pe.th32ParentProcessID;
}
} while (Process32Next(h, &pe));
}
CloseHandle(h);
return res;
}
bool IsFileManagerApp(std::wstring processPath)
{
std::wstring appName = std::filesystem::path(processPath).stem();
std::transform(appName.begin(), appName.end(), appName.begin(), towupper);
return ((appName == NonLocalizable::FileManagers::FileExplorer) // windows explorer
|| (appName.starts_with(NonLocalizable::FileManagers::TotalCommander)) // total commander
|| (appName == NonLocalizable::FileManagers::DirectoryOpus) // directory opus
|| (appName == NonLocalizable::FileManagers::QDir) // Q-Dir
|| (appName.starts_with(NonLocalizable::FileManagers::Xplorer2))); // Xplorer2
}
std::vector<WorkspacesData::WorkspacesProject::Application> GetApps(const std::function<unsigned int(HWND)> getMonitorNumberFromWindowHandle)
{
std::vector<WorkspacesData::WorkspacesProject::Application> apps{};
@@ -285,83 +242,17 @@ namespace SnapshotUtils
continue;
}
auto data = Utils::Apps::GetApp(processPath, installedApps);
auto data = Utils::Apps::GetApp(processPath, pid, installedApps);
if (!data.has_value() || data->name.empty())
{
Logger::info(L"Installed app not found: {}, try parent process", processPath);
bool standaloneApp = false;
bool steamLikeApp = false;
// try with parent process (fix for Steam)
auto parentPid = GetParentPid(pid);
auto parentProcessPath = get_process_path(parentPid);
// check if original process is in the subfolder of the parent process which is a sign of an steam-like app
std::wstring processDir = std::filesystem::path(processPath).parent_path().c_str();
std::wstring parentProcessDir = std::filesystem::path(parentProcessPath).parent_path().c_str();
if (parentProcessPath == L"")
{
if (processPath.ends_with(NonLocalizable::ApplicationFrameHost))
{
// filter out ApplicationFrameHost.exe
continue;
}
else
{
Logger::info(L"parent process unknown, the parent app is an already closed file manager app, it is a standalone app");
standaloneApp = true;
}
}
else if (processDir.starts_with(parentProcessDir))
{
Logger::info(L"parent process: {}, original process is in the subfolder of the parent process, it is a steam-like app", parentProcessPath);
steamLikeApp = true;
}
else if (IsFileManagerApp(parentProcessPath))
{
Logger::info(L"parent process: {}, The parent process is a known file manager app, it is a standalone app", parentProcessPath);
standaloneApp = true;
}
else
{
Logger::info(L"parent process: {}, The parent process is NOT a known file manager app, it is a steam-like app", parentProcessPath);
steamLikeApp = true;
}
if (standaloneApp)
{
data = Utils::Apps::AppData{
.name = std::filesystem::path(processPath).stem(),
.installPath = processPath,
};
}
else if (steamLikeApp)
{
if (!parentProcessPath.empty())
{
data = Utils::Apps::GetApp(parentProcessPath, installedApps);
if (!data.has_value() || data->name.empty())
{
Logger::info(L"Installed parent app not found: {}", processPath);
continue;
}
processPath = parentProcessPath;
}
else
{
Logger::info(L"Parent process path not found");
continue;
}
}
Logger::info(L"Installed app not found: {}", processPath);
continue;
}
WorkspacesData::WorkspacesProject::Application app{
.name = data.value().name,
.title = title,
.path = processPath,
.path = data.value().installPath,
.packageFullName = data.value().packageFullName,
.appUserModelId = data.value().appUserModelId,
.commandLineArgs = L"", // GetCommandLineArgs(pid, wbemHelper),

View File

@@ -161,19 +161,16 @@ void WindowArranger::processWindow(HWND window)
return;
}
std::wstring title = WindowUtils::GetWindowTitle(window);
if (title.empty())
{
return;
}
std::wstring processPath = get_process_path(window);
if (processPath.empty())
{
return;
}
auto data = Utils::Apps::GetApp(processPath, m_installedApps);
DWORD pid{};
GetWindowThreadProcessId(window, &pid);
auto data = Utils::Apps::GetApp(processPath, pid, m_installedApps);
if (!data.has_value())
{
return;
@@ -189,7 +186,6 @@ void WindowArranger::processWindow(HWND window)
return;
}
Logger::debug(L"Move {}", title);
iter->second.window = window;
if (moveWindow(window, iter->first))
{

View File

@@ -14,7 +14,6 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Threading;
using Awake.Core.Models;
using Awake.Core.Native;
using Awake.Properties;

View File

@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using ManagedCommon;
namespace Awake.Core.Threading
{
@@ -49,7 +50,7 @@ namespace Awake.Core.Threading
}
catch (Exception e)
{
Console.WriteLine("Error during execution: " + e.Message);
Logger.LogError("Error during execution of the STS context message loop: " + e.Message);
}
}
}
@@ -58,7 +59,8 @@ namespace Awake.Core.Threading
{
lock (queue)
{
queue.Enqueue(null); // Signal the end of the message loop
// Signal the end of the message loop
queue.Enqueue(null);
Monitor.Pulse(queue);
}
}

View File

@@ -15,7 +15,6 @@ using System.Reflection;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Awake.Core;
using Awake.Core.Models;
using Awake.Core.Native;

View File

@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class NewPlusProperties
{
public const string ModuleName = "NewPlus";
public NewPlusProperties()
{
HideFileExtension = new BoolProperty(true);
HideStartingDigits = new BoolProperty(true);
TemplateLocation = new StringProperty(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "NewPlus", "Templates"));
}
[JsonPropertyName("HideFileExtension")]
public BoolProperty HideFileExtension { get; set; }
[JsonPropertyName("HideStartingDigits")]
public BoolProperty HideStartingDigits { get; set; }
[JsonPropertyName("TemplateLocation")]
public StringProperty TemplateLocation { get; set; }
public override string ToString() => JsonSerializer.Serialize(this);
}
}

View File

@@ -12,34 +12,27 @@ using Settings.UI.Library.Resources;
namespace Microsoft.PowerToys.Settings.UI.Library
{
public class NewPlusSettings : ISettingsConfig
public class NewPlusSettings : BasePTModuleSettings, ISettingsConfig
{
public const string ModuleName = "NewPlus";
public const string ModuleVersion = "1.0";
public void InitializeWithDefaultSettings()
[JsonPropertyName("properties")]
public NewPlusProperties Properties { get; set; }
public NewPlusSettings()
{
// This code path should never happen
Name = ModuleName;
Version = ModuleVersion;
Properties = new NewPlusProperties();
}
public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
[JsonPropertyName("HideFileExtension")]
public bool HideFileExtension { get; set; }
[JsonPropertyName("HideStartingDigits")]
public bool HideStartingDigits { get; set; }
[JsonPropertyName("TemplateLocation")]
public string TemplateLocation { get; set; }
public string GetModuleName()
{
return ModuleName;
return Name;
}
// This can be utilized in the future if the settings.json file is to be modified/deleted.
public bool UpgradeSettingsConfiguration()
{
return false;

View File

@@ -130,7 +130,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
var settingsUtils = new SettingsUtils();
var settings = NewPlusViewModel.LoadSettings(settingsUtils);
NewPlusViewModel.CopyTemplateExamples(settings.TemplateLocation);
NewPlusViewModel.CopyTemplateExamples(settings.Properties.TemplateLocation.Value);
}
}

View File

@@ -47,9 +47,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
Settings = LoadSettings(settingsUtils);
// Initialize properties
_hideFileExtension = Settings.HideFileExtension;
_hideStartingDigits = Settings.HideStartingDigits;
_templateLocation = Settings.TemplateLocation;
_hideFileExtension = Settings.Properties.HideFileExtension.Value;
_hideStartingDigits = Settings.Properties.HideStartingDigits.Value;
_templateLocation = Settings.Properties.TemplateLocation.Value;
InitializeEnabledValue();
InitializeGpoValues();
@@ -119,12 +119,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (_templateLocation != value)
{
_templateLocation = value;
Settings.TemplateLocation = value;
Settings.Properties.TemplateLocation.Value = value;
OnPropertyChanged(nameof(TemplateLocation));
NotifySettingsChanged();
SaveSettingsToJson();
}
}
}
@@ -146,12 +144,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (_hideFileExtension != value && !_hideFileExtensionIsGPOConfigured)
{
_hideFileExtension = value;
Settings.HideFileExtension = value;
Settings.Properties.HideFileExtension.Value = value;
OnPropertyChanged(nameof(HideFileExtension));
NotifySettingsChanged();
SaveSettingsToJson();
}
}
}
@@ -168,12 +164,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
if (_hideStartingDigits != value)
{
_hideStartingDigits = value;
Settings.HideStartingDigits = value;
Settings.Properties.HideStartingDigits.Value = value;
OnPropertyChanged(nameof(HideStartingDigits));
NotifySettingsChanged();
SaveSettingsToJson();
}
}
}
@@ -208,10 +202,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
settings = settingsUtils.GetSettingsOrDefault<NewPlusSettings>(NewPlusSettings.ModuleName);
if (string.IsNullOrEmpty(settings.TemplateLocation))
if (string.IsNullOrEmpty(settings.Properties.TemplateLocation.Value))
{
// This can happen when running the DEBUG Settings application without first letting the runner create the default settings file.
settings.TemplateLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "NewPlus", "Templates");
settings.Properties.TemplateLocation.Value = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "NewPlus", "Templates");
}
}
catch (Exception e)
@@ -278,10 +272,5 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.GetSettingsWindow());
return await Task.FromResult(GetFolderDialogWithFlags(hwnd, FolderDialogFlags._BIF_NEWDIALOGSTYLE));
}
private void SaveSettingsToJson()
{
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
}
}
}