2019-09-04 18:26:26 +02:00
|
|
|
#include "pch.h"
|
|
|
|
#include <WinSafer.h>
|
|
|
|
#include <Sddl.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <aclapi.h>
|
2019-12-06 11:40:23 +03:00
|
|
|
|
2019-09-04 18:26:26 +02:00
|
|
|
#include "powertoy_module.h"
|
2020-12-15 15:16:09 +03:00
|
|
|
#include <common/interop/two_way_pipe_message_ipc.h>
|
2019-09-04 18:26:26 +02:00
|
|
|
#include "tray_icon.h"
|
|
|
|
#include "general_settings.h"
|
2019-12-16 18:36:52 +01:00
|
|
|
#include "restart_elevated.h"
|
2021-06-14 12:55:59 +03:00
|
|
|
#include "UpdateUtils.h"
|
2020-09-21 12:44:16 +02:00
|
|
|
#include "centralized_kb_hook.h"
|
2023-01-31 00:00:11 +01:00
|
|
|
#include "Generated files/resource.h"
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2020-12-15 15:16:09 +03:00
|
|
|
#include <common/utils/json.h>
|
|
|
|
#include <common/SettingsAPI/settings_helpers.cpp>
|
|
|
|
#include <common/version/version.h>
|
|
|
|
#include <common/version/helper.h>
|
2020-11-30 16:16:49 +02:00
|
|
|
#include <common/logger/logger.h>
|
2023-01-31 00:00:11 +01:00
|
|
|
#include <common/utils/resources.h>
|
2020-12-15 15:16:09 +03:00
|
|
|
#include <common/utils/elevation.h>
|
2020-12-17 19:38:23 +03:00
|
|
|
#include <common/utils/process_path.h>
|
|
|
|
#include <common/utils/timeutil.h>
|
|
|
|
#include <common/utils/winapi_error.h>
|
2021-05-21 13:32:34 +03:00
|
|
|
#include <common/updating/updateState.h>
|
|
|
|
#include <common/themes/windows_colors.h>
|
2021-09-29 12:54:05 +02:00
|
|
|
#include "settings_window.h"
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-06 11:40:23 +03:00
|
|
|
#define BUFSIZE 1024
|
2019-09-04 18:26:26 +02:00
|
|
|
|
|
|
|
TwoWayPipeMessageIPC* current_settings_ipc = NULL;
|
2022-11-22 16:58:49 +00:00
|
|
|
std::mutex ipc_mutex;
|
2020-05-14 09:12:40 -07:00
|
|
|
std::atomic_bool g_isLaunchInProgress = false;
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
json::JsonObject get_power_toys_settings()
|
|
|
|
{
|
|
|
|
json::JsonObject result;
|
|
|
|
for (const auto& [name, powertoy] : modules())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.SetNamedValue(name, powertoy.json_config());
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2021-05-20 15:07:34 +03:00
|
|
|
Logger::error(L"get_power_toys_settings(): got malformed json for {} module", name);
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
return result;
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
json::JsonObject get_all_settings()
|
|
|
|
{
|
|
|
|
json::JsonObject result;
|
2019-12-06 11:40:23 +03:00
|
|
|
|
2020-04-21 10:30:12 +03:00
|
|
|
result.SetNamedValue(L"general", get_general_settings().to_json());
|
2019-12-11 15:39:05 +01:00
|
|
|
result.SetNamedValue(L"powertoys", get_power_toys_settings());
|
|
|
|
return result;
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 11:56:52 +03:00
|
|
|
std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObject& powertoys_configs)
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
2020-09-04 11:56:52 +03:00
|
|
|
std::optional<std::wstring> result;
|
2019-12-11 15:39:05 +01:00
|
|
|
for (const auto& powertoy_element : powertoys_configs)
|
|
|
|
{
|
|
|
|
const std::wstring name{ powertoy_element.Key().c_str() };
|
2019-12-16 18:36:52 +01:00
|
|
|
// Currently, there is only one custom action in the general settings screen,
|
|
|
|
// so it has to be the "restart as (non-)elevated" button.
|
|
|
|
if (name == L"general")
|
|
|
|
{
|
2020-06-23 15:53:02 +03:00
|
|
|
try
|
2019-12-16 18:36:52 +01:00
|
|
|
{
|
2020-06-23 15:53:02 +03:00
|
|
|
const auto value = powertoy_element.Value().GetObjectW();
|
|
|
|
const auto action = value.GetNamedString(L"action_name");
|
|
|
|
if (action == L"restart_elevation")
|
|
|
|
{
|
|
|
|
if (is_process_elevated())
|
|
|
|
{
|
|
|
|
schedule_restart_as_non_elevated();
|
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-10 14:48:43 +01:00
|
|
|
schedule_restart_as_elevated(true);
|
2020-06-23 15:53:02 +03:00
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
}
|
2022-10-13 03:41:21 -04:00
|
|
|
else if (action == L"restart_maintain_elevation")
|
|
|
|
{
|
|
|
|
// this was added to restart and maintain elevation, which is needed after settings are change from outside the normal process.
|
2022-11-09 14:41:14 +00:00
|
|
|
// since a normal PostQuitMessage(0) would usually cause this process to save it's in memory settings to disk, we need to
|
2022-10-13 03:41:21 -04:00
|
|
|
// send a PostQuitMessage(1) and check for that on exit, and skip the settings-flush.
|
|
|
|
auto loaded = PTSettingsHelper::load_general_settings();
|
|
|
|
|
|
|
|
if (is_process_elevated())
|
|
|
|
{
|
|
|
|
schedule_restart_as_elevated(true);
|
|
|
|
PostQuitMessage(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
schedule_restart_as_non_elevated(true);
|
|
|
|
PostQuitMessage(1);
|
|
|
|
}
|
|
|
|
}
|
2020-06-23 15:53:02 +03:00
|
|
|
else if (action == L"check_for_updates")
|
|
|
|
{
|
2021-06-14 12:55:59 +03:00
|
|
|
CheckForUpdatesCallback();
|
2020-12-17 19:38:23 +03:00
|
|
|
}
|
|
|
|
else if (action == L"request_update_state_date")
|
|
|
|
{
|
|
|
|
json::JsonObject json;
|
|
|
|
|
|
|
|
auto update_state = UpdateState::read();
|
2021-05-21 13:32:34 +03:00
|
|
|
if (update_state.githubUpdateLastCheckedDate)
|
2020-12-17 19:38:23 +03:00
|
|
|
{
|
2021-05-21 13:32:34 +03:00
|
|
|
const time_t date = *update_state.githubUpdateLastCheckedDate;
|
2021-01-12 18:34:02 +03:00
|
|
|
json.SetNamedValue(L"updateStateDate", json::value(std::to_wstring(date)));
|
2020-12-17 19:38:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-04 11:56:52 +03:00
|
|
|
result.emplace(json.Stringify());
|
2020-06-23 15:53:02 +03:00
|
|
|
}
|
2019-12-16 18:36:52 +01:00
|
|
|
}
|
2020-06-23 15:53:02 +03:00
|
|
|
catch (...)
|
2019-12-16 18:36:52 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (modules().find(name) != modules().end())
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
|
|
|
const auto element = powertoy_element.Value().Stringify();
|
2020-03-13 12:55:15 +03:00
|
|
|
modules().at(name)->call_custom_action(element.c_str());
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
2020-10-12 11:57:50 +03:00
|
|
|
|
|
|
|
return result;
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
void send_json_config_to_module(const std::wstring& module_key, const std::wstring& settings)
|
|
|
|
{
|
2020-09-21 12:44:16 +02:00
|
|
|
auto moduleIt = modules().find(module_key);
|
|
|
|
if (moduleIt != modules().end())
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
2020-09-21 12:44:16 +02:00
|
|
|
moduleIt->second->set_config(settings.c_str());
|
|
|
|
moduleIt->second.update_hotkeys();
|
2021-05-20 15:07:34 +03:00
|
|
|
moduleIt->second.UpdateHotkeyEx();
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
void dispatch_json_config_to_modules(const json::JsonObject& powertoys_configs)
|
|
|
|
{
|
|
|
|
for (const auto& powertoy_element : powertoys_configs)
|
|
|
|
{
|
|
|
|
const auto element = powertoy_element.Value().Stringify();
|
|
|
|
send_json_config_to_module(powertoy_element.Key().c_str(), element.c_str());
|
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
};
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
void dispatch_received_json(const std::wstring& json_to_parse)
|
|
|
|
{
|
2021-01-12 20:42:16 +03:00
|
|
|
json::JsonObject j;
|
|
|
|
const bool ok = json::JsonObject::TryParse(json_to_parse, j);
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
Logger::error(L"dispatch_received_json: got malformed json: {}", json_to_parse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
for (const auto& base_element : j)
|
|
|
|
{
|
|
|
|
const auto name = base_element.Key();
|
|
|
|
const auto value = base_element.Value();
|
|
|
|
|
|
|
|
if (name == L"general")
|
|
|
|
{
|
|
|
|
apply_general_settings(value.GetObjectW());
|
2020-12-29 13:56:10 +03:00
|
|
|
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
|
2022-11-22 16:58:49 +00:00
|
|
|
{
|
|
|
|
std::unique_lock lock{ ipc_mutex };
|
2023-01-31 00:00:11 +01:00
|
|
|
if (current_settings_ipc)
|
2022-11-22 16:58:49 +00:00
|
|
|
current_settings_ipc->send(settings_string);
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
|
|
|
else if (name == L"powertoys")
|
|
|
|
{
|
|
|
|
dispatch_json_config_to_modules(value.GetObjectW());
|
2020-12-29 13:56:10 +03:00
|
|
|
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
|
2022-11-22 16:58:49 +00:00
|
|
|
{
|
|
|
|
std::unique_lock lock{ ipc_mutex };
|
2023-01-31 00:00:11 +01:00
|
|
|
if (current_settings_ipc)
|
2022-11-22 16:58:49 +00:00
|
|
|
current_settings_ipc->send(settings_string);
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
|
|
|
else if (name == L"refresh")
|
|
|
|
{
|
2020-12-29 13:56:10 +03:00
|
|
|
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
|
2022-11-22 16:58:49 +00:00
|
|
|
{
|
|
|
|
std::unique_lock lock{ ipc_mutex };
|
2023-01-31 00:00:11 +01:00
|
|
|
if (current_settings_ipc)
|
2022-11-22 16:58:49 +00:00
|
|
|
current_settings_ipc->send(settings_string);
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
|
|
|
else if (name == L"action")
|
|
|
|
{
|
2020-09-04 11:56:52 +03:00
|
|
|
auto result = dispatch_json_action_to_module(value.GetObjectW());
|
|
|
|
if (result.has_value())
|
|
|
|
{
|
2022-11-22 16:58:49 +00:00
|
|
|
{
|
|
|
|
std::unique_lock lock{ ipc_mutex };
|
2023-01-31 00:00:11 +01:00
|
|
|
if (current_settings_ipc)
|
2022-11-22 16:58:49 +00:00
|
|
|
current_settings_ipc->send(result.value());
|
|
|
|
}
|
2020-09-04 11:56:52 +03:00
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
else if (name == L"bugreport")
|
|
|
|
{
|
|
|
|
std::wstring bug_report_path = get_module_folderpath();
|
|
|
|
bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
|
|
|
|
SHELLEXECUTEINFOW sei{ sizeof(sei) };
|
|
|
|
sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
|
|
|
|
sei.lpFile = bug_report_path.c_str();
|
|
|
|
sei.nShow = SW_HIDE;
|
|
|
|
if (ShellExecuteExW(&sei))
|
|
|
|
{
|
|
|
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
|
|
CloseHandle(sei.hProcess);
|
|
|
|
static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
|
|
|
|
MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == L"killrunner")
|
|
|
|
{
|
|
|
|
const auto pt_main_window = FindWindowW(pt_tray_icon_window_class, nullptr);
|
|
|
|
if (pt_main_window != nullptr)
|
|
|
|
{
|
|
|
|
SendMessageW(pt_main_window, WM_CLOSE, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
return;
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
void dispatch_received_json_callback(PVOID data)
|
|
|
|
{
|
2023-02-08 11:17:33 +00:00
|
|
|
std::wstring* msg = static_cast<std::wstring*>(data);
|
2019-12-11 15:39:05 +01:00
|
|
|
dispatch_received_json(*msg);
|
|
|
|
delete msg;
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
void receive_json_send_to_main_thread(const std::wstring& msg)
|
|
|
|
{
|
|
|
|
std::wstring* copy = new std::wstring(msg);
|
|
|
|
dispatch_run_on_main_ui_thread(dispatch_received_json_callback, copy);
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 00:30:34 +02:00
|
|
|
// Try to run the Settings process with non-elevated privileges.
|
|
|
|
BOOL run_settings_non_elevated(LPCWSTR executable_path, LPWSTR executable_args, PROCESS_INFORMATION* process_info)
|
|
|
|
{
|
|
|
|
HWND hwnd = GetShellWindow();
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD pid;
|
|
|
|
GetWindowThreadProcessId(hwnd, &pid);
|
|
|
|
|
|
|
|
winrt::handle process{ OpenProcess(PROCESS_CREATE_PROCESS, FALSE, pid) };
|
|
|
|
if (!process)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SIZE_T size = 0;
|
|
|
|
InitializeProcThreadAttributeList(nullptr, 1, 0, &size);
|
|
|
|
auto pproc_buffer = std::unique_ptr<char[]>{ new (std::nothrow) char[size] };
|
|
|
|
auto pptal = reinterpret_cast<PPROC_THREAD_ATTRIBUTE_LIST>(pproc_buffer.get());
|
|
|
|
if (!pptal)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!InitializeProcThreadAttributeList(pptal, 1, 0, &size))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UpdateProcThreadAttribute(pptal,
|
|
|
|
0,
|
|
|
|
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
|
|
|
|
&process,
|
|
|
|
sizeof(process),
|
|
|
|
nullptr,
|
|
|
|
nullptr))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
STARTUPINFOEX siex = { 0 };
|
|
|
|
siex.lpAttributeList = pptal;
|
|
|
|
siex.StartupInfo.cb = sizeof(siex);
|
|
|
|
|
|
|
|
BOOL process_created = CreateProcessW(executable_path,
|
|
|
|
executable_args,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
FALSE,
|
|
|
|
EXTENDED_STARTUPINFO_PRESENT,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&siex.StartupInfo,
|
|
|
|
process_info);
|
|
|
|
g_isLaunchInProgress = false;
|
|
|
|
return process_created;
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:32:40 +01:00
|
|
|
DWORD g_settings_process_id = 0;
|
|
|
|
|
2023-02-03 15:10:14 +00:00
|
|
|
void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::optional<std::wstring> settings_window, bool show_flyout = false, const std::optional<POINT>& flyout_position = std::nullopt)
|
2019-12-11 16:32:40 +01:00
|
|
|
{
|
2020-05-14 09:12:40 -07:00
|
|
|
g_isLaunchInProgress = true;
|
|
|
|
|
2019-12-11 16:32:40 +01:00
|
|
|
PROCESS_INFORMATION process_info = { 0 };
|
|
|
|
HANDLE hToken = nullptr;
|
|
|
|
|
|
|
|
// Arguments for calling the settings executable:
|
|
|
|
// "C:\powertoys_path\PowerToysSettings.exe" powertoys_pipe settings_pipe powertoys_pid settings_theme
|
|
|
|
// powertoys_pipe: PowerToys pipe server.
|
|
|
|
// settings_pipe : Settings pipe server.
|
|
|
|
// powertoys_pid : PowerToys process pid.
|
|
|
|
// settings_theme: pass "dark" to start the settings window in dark mode
|
|
|
|
|
|
|
|
// Arg 1: executable path.
|
|
|
|
std::wstring executable_path = get_module_folderpath();
|
2020-05-05 15:53:30 -07:00
|
|
|
|
2021-04-05 02:32:48 -07:00
|
|
|
executable_path.append(L"\\Settings\\PowerToys.Settings.exe");
|
2019-12-11 16:32:40 +01:00
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Args 2,3: pipe server. Generate unique names for the pipes, if getting a UUID is possible.
|
2019-12-11 16:32:40 +01:00
|
|
|
std::wstring powertoys_pipe_name(L"\\\\.\\pipe\\powertoys_runner_");
|
|
|
|
std::wstring settings_pipe_name(L"\\\\.\\pipe\\powertoys_settings_");
|
|
|
|
UUID temp_uuid;
|
2020-11-30 16:16:49 +02:00
|
|
|
wchar_t* uuid_chars = nullptr;
|
|
|
|
if (UuidCreate(&temp_uuid) == RPC_S_UUID_NO_ADDRESS)
|
|
|
|
{
|
|
|
|
auto val = get_last_error_message(GetLastError());
|
|
|
|
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
|
|
|
}
|
2023-02-08 11:17:33 +00:00
|
|
|
else if (UuidToString(&temp_uuid, reinterpret_cast<RPC_WSTR*>(&uuid_chars)) != RPC_S_OK)
|
2020-11-30 16:16:49 +02:00
|
|
|
{
|
|
|
|
auto val = get_last_error_message(GetLastError());
|
|
|
|
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:32:40 +01:00
|
|
|
if (uuid_chars != nullptr)
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
2019-12-11 16:32:40 +01:00
|
|
|
powertoys_pipe_name += std::wstring(uuid_chars);
|
|
|
|
settings_pipe_name += std::wstring(uuid_chars);
|
2023-02-08 11:17:33 +00:00
|
|
|
RpcStringFree(reinterpret_cast<RPC_WSTR*>(&uuid_chars));
|
2019-12-11 16:32:40 +01:00
|
|
|
uuid_chars = nullptr;
|
|
|
|
}
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Arg 4: process pid.
|
2019-12-11 16:32:40 +01:00
|
|
|
DWORD powertoys_pid = GetCurrentProcessId();
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Arg 5: settings theme.
|
2020-04-21 10:30:12 +03:00
|
|
|
const std::wstring settings_theme_setting{ get_general_settings().theme };
|
2020-05-05 21:17:43 -07:00
|
|
|
std::wstring settings_theme = L"system";
|
2019-12-11 16:32:40 +01:00
|
|
|
if (settings_theme_setting == L"dark" || (settings_theme_setting == L"system" && WindowsColors::is_dark_mode()))
|
|
|
|
{
|
|
|
|
settings_theme = L"dark";
|
|
|
|
}
|
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Arg 6: elevated status
|
2020-05-05 10:02:31 -07:00
|
|
|
bool isElevated{ get_general_settings().isElevated };
|
2021-03-02 20:56:37 +03:00
|
|
|
std::wstring settings_elevatedStatus = isElevated ? L"true" : L"false";
|
2021-05-21 13:32:34 +03:00
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Arg 7: is user an admin
|
2020-05-14 12:36:27 +03:00
|
|
|
bool isAdmin{ get_general_settings().isAdmin };
|
2021-03-02 20:56:37 +03:00
|
|
|
std::wstring settings_isUserAnAdmin = isAdmin ? L"true" : L"false";
|
2020-05-14 12:36:27 +03:00
|
|
|
|
2021-03-02 20:56:37 +03:00
|
|
|
// Arg 8: should oobe window be shown
|
2021-09-29 12:54:05 +02:00
|
|
|
std::wstring settings_showOobe = show_oobe_window ? L"true" : L"false";
|
2020-05-14 12:36:27 +03:00
|
|
|
|
2022-02-22 11:02:08 +00:00
|
|
|
// Arg 9: should scoobe window be shown
|
|
|
|
std::wstring settings_showScoobe = show_scoobe_window ? L"true" : L"false";
|
|
|
|
|
2023-01-31 00:00:11 +01:00
|
|
|
// Arg 10: should flyout be shown
|
|
|
|
std::wstring settings_showFlyout = show_flyout ? L"true" : L"false";
|
|
|
|
|
2023-02-03 15:10:14 +00:00
|
|
|
// Arg 11: contains if there's a settings window argument. If true, will add one extra argument with the value to the call.
|
|
|
|
std::wstring settings_containsSettingsWindow = settings_window.has_value() ? L"true" : L"false";
|
|
|
|
|
|
|
|
// Arg 12: contains if there's flyout coordinates. If true, will add two extra arguments to the call containing the x and y coordinates.
|
|
|
|
std::wstring settings_containsFlyoutPosition = flyout_position.has_value() ? L"true" : L"false";
|
|
|
|
|
|
|
|
// Args 13, .... : Optional arguments depending on the options presented before. All by the same value.
|
|
|
|
|
|
|
|
std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {} {} {} {}",
|
|
|
|
executable_path,
|
|
|
|
powertoys_pipe_name,
|
|
|
|
settings_pipe_name,
|
|
|
|
std::to_wstring(powertoys_pid),
|
|
|
|
settings_theme,
|
|
|
|
settings_elevatedStatus,
|
|
|
|
settings_isUserAnAdmin,
|
|
|
|
settings_showOobe,
|
|
|
|
settings_showScoobe,
|
|
|
|
settings_showFlyout,
|
|
|
|
settings_containsSettingsWindow,
|
|
|
|
settings_containsFlyoutPosition);
|
2021-05-21 13:32:34 +03:00
|
|
|
|
2021-09-29 12:54:05 +02:00
|
|
|
if (settings_window.has_value())
|
|
|
|
{
|
|
|
|
executable_args.append(L" ");
|
|
|
|
executable_args.append(settings_window.value());
|
|
|
|
}
|
|
|
|
|
2023-02-03 15:10:14 +00:00
|
|
|
if (flyout_position)
|
|
|
|
{
|
|
|
|
executable_args.append(L" ");
|
|
|
|
executable_args.append(std::to_wstring(flyout_position.value().x));
|
|
|
|
executable_args.append(L" ");
|
|
|
|
executable_args.append(std::to_wstring(flyout_position.value().y));
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:32:40 +01:00
|
|
|
BOOL process_created = false;
|
2021-01-20 19:28:14 +01:00
|
|
|
|
2022-12-16 15:14:50 +01:00
|
|
|
// Commented out to fix #22659
|
|
|
|
// Running settings non-elevated and modules elevated when PowerToys is running elevated results
|
|
|
|
// in settings making changes in one file (non-elevated user dir) and modules are reading settings
|
|
|
|
// from different (elevated user) dir
|
|
|
|
//if (is_process_elevated())
|
|
|
|
//{
|
|
|
|
|
|
|
|
// auto res = RunNonElevatedFailsafe(executable_path, executable_args, get_module_folderpath());
|
|
|
|
// process_created = res.has_value();
|
|
|
|
// if (process_created)
|
|
|
|
// {
|
|
|
|
// process_info.dwProcessId = res->processID;
|
|
|
|
// process_info.hProcess = res->processHandle.release();
|
|
|
|
// g_isLaunchInProgress = false;
|
|
|
|
// }
|
|
|
|
//}
|
2019-12-11 16:32:40 +01:00
|
|
|
|
|
|
|
if (FALSE == process_created)
|
|
|
|
{
|
|
|
|
// The runner is not elevated or we failed to create the process using the
|
|
|
|
// attribute list from Windows Explorer (this happens when PowerToys is executed
|
|
|
|
// as Administrator from a non-Administrator user or an error occur trying).
|
|
|
|
// In the second case the Settings process will run elevated.
|
|
|
|
STARTUPINFO startup_info = { sizeof(startup_info) };
|
|
|
|
if (!CreateProcessW(executable_path.c_str(),
|
|
|
|
executable_args.data(),
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&startup_info,
|
|
|
|
&process_info))
|
|
|
|
{
|
|
|
|
goto LExit;
|
|
|
|
}
|
2020-05-14 09:12:40 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_isLaunchInProgress = false;
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
|
|
|
|
{
|
|
|
|
goto LExit;
|
|
|
|
}
|
2019-12-11 16:32:40 +01:00
|
|
|
|
2022-11-22 16:58:49 +00:00
|
|
|
{
|
|
|
|
std::unique_lock lock{ ipc_mutex };
|
|
|
|
current_settings_ipc = new TwoWayPipeMessageIPC(powertoys_pipe_name, settings_pipe_name, receive_json_send_to_main_thread);
|
|
|
|
current_settings_ipc->start(hToken);
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
g_settings_process_id = process_info.dwProcessId;
|
|
|
|
|
2020-11-30 16:16:49 +02:00
|
|
|
if (process_info.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(process_info.hProcess, INFINITE);
|
|
|
|
if (WaitForSingleObject(process_info.hProcess, INFINITE) != WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
show_last_error_message(L"Couldn't wait on the Settings Window to close.", GetLastError(), L"PowerToys - runner");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
2020-11-30 16:16:49 +02:00
|
|
|
auto val = get_last_error_message(GetLastError());
|
|
|
|
Logger::error(L"Process handle is empty. {}", val.has_value() ? val.value() : L"");
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
LExit:
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
if (process_info.hProcess)
|
|
|
|
{
|
|
|
|
CloseHandle(process_info.hProcess);
|
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
if (process_info.hThread)
|
|
|
|
{
|
|
|
|
CloseHandle(process_info.hThread);
|
|
|
|
}
|
|
|
|
{
|
2022-11-22 16:58:49 +00:00
|
|
|
std::unique_lock lock{ ipc_mutex };
|
|
|
|
if (current_settings_ipc)
|
|
|
|
{
|
|
|
|
current_settings_ipc->end();
|
|
|
|
delete current_settings_ipc;
|
|
|
|
current_settings_ipc = nullptr;
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
|
2019-12-11 15:39:05 +01:00
|
|
|
if (hToken)
|
|
|
|
{
|
|
|
|
CloseHandle(hToken);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings_process_id = 0;
|
|
|
|
}
|
|
|
|
|
2020-05-05 14:02:55 -07:00
|
|
|
#define MAX_TITLE_LENGTH 100
|
2019-12-11 15:39:05 +01:00
|
|
|
void bring_settings_to_front()
|
|
|
|
{
|
2022-11-09 14:41:14 +00:00
|
|
|
auto callback = [](HWND hwnd, LPARAM /*data*/) -> BOOL {
|
2019-12-11 15:39:05 +01:00
|
|
|
DWORD processId;
|
|
|
|
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
|
|
|
|
{
|
2020-05-05 14:02:55 -07:00
|
|
|
std::wstring windowTitle = L"PowerToys Settings";
|
|
|
|
|
|
|
|
WCHAR title[MAX_TITLE_LENGTH];
|
|
|
|
int len = GetWindowTextW(hwnd, title, MAX_TITLE_LENGTH);
|
|
|
|
if (len <= 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (wcsncmp(title, windowTitle.c_str(), len) == 0)
|
|
|
|
{
|
2021-11-18 12:38:16 +01:00
|
|
|
auto lStyles = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
|
|
|
|
if (lStyles & WS_MAXIMIZE)
|
|
|
|
{
|
|
|
|
ShowWindow(hwnd, SW_MAXIMIZE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
}
|
|
|
|
|
2020-05-05 14:02:55 -07:00
|
|
|
SetForegroundWindow(hwnd);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumWindows(callback, 0);
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
|
|
|
|
2023-02-03 15:10:14 +00:00
|
|
|
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout = false, const std::optional<POINT>& flyout_position)
|
2019-12-11 15:39:05 +01:00
|
|
|
{
|
|
|
|
if (g_settings_process_id != 0)
|
|
|
|
{
|
2023-01-31 00:00:11 +01:00
|
|
|
if (show_flyout)
|
|
|
|
{
|
|
|
|
if (current_settings_ipc)
|
|
|
|
{
|
2023-02-03 15:10:14 +00:00
|
|
|
if (!flyout_position.has_value())
|
|
|
|
{
|
|
|
|
current_settings_ipc->send(L"{\"ShowYourself\":\"flyout\"}");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_settings_ipc->send(fmt::format(L"{{\"ShowYourself\":\"flyout\", \"x_position\":{}, \"y_position\":{} }}", std::to_wstring(flyout_position.value().x), std::to_wstring(flyout_position.value().y)));
|
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// nl instead of showing the window, send message to it (flyout might need to be hidden, main setting window activated)
|
|
|
|
// bring_settings_to_front();
|
|
|
|
if (current_settings_ipc)
|
|
|
|
{
|
|
|
|
current_settings_ipc->send(L"{\"ShowYourself\":\"main_page\"}");
|
|
|
|
}
|
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 09:12:40 -07:00
|
|
|
if (!g_isLaunchInProgress)
|
|
|
|
{
|
2023-02-03 15:10:14 +00:00
|
|
|
std::thread([settings_window, show_flyout, flyout_position]() {
|
|
|
|
run_settings_window(false, false, settings_window, show_flyout, flyout_position);
|
2021-03-02 20:56:37 +03:00
|
|
|
}).detach();
|
2020-05-14 09:12:40 -07:00
|
|
|
}
|
2019-12-11 15:39:05 +01:00
|
|
|
}
|
2019-09-04 18:26:26 +02:00
|
|
|
}
|
2020-05-05 14:13:52 -07:00
|
|
|
|
|
|
|
void close_settings_window()
|
|
|
|
{
|
|
|
|
if (g_settings_process_id != 0)
|
|
|
|
{
|
|
|
|
HANDLE proc = OpenProcess(PROCESS_TERMINATE, false, g_settings_process_id);
|
|
|
|
if (proc != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
TerminateProcess(proc, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-02 20:56:37 +03:00
|
|
|
|
|
|
|
void open_oobe_window()
|
|
|
|
{
|
|
|
|
std::thread([]() {
|
2022-02-22 11:02:08 +00:00
|
|
|
run_settings_window(true, false, std::nullopt);
|
|
|
|
}).detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
void open_scoobe_window()
|
|
|
|
{
|
|
|
|
std::thread([]() {
|
|
|
|
run_settings_window(false, true, std::nullopt);
|
2021-03-02 20:56:37 +03:00
|
|
|
}).detach();
|
|
|
|
}
|
2021-09-29 12:54:05 +02:00
|
|
|
|
|
|
|
std::string ESettingsWindowNames_to_string(ESettingsWindowNames value)
|
|
|
|
{
|
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case ESettingsWindowNames::Overview:
|
|
|
|
return "Overview";
|
|
|
|
case ESettingsWindowNames::Awake:
|
|
|
|
return "Awake";
|
|
|
|
case ESettingsWindowNames::ColorPicker:
|
|
|
|
return "ColorPicker";
|
|
|
|
case ESettingsWindowNames::FancyZones:
|
|
|
|
return "FancyZones";
|
|
|
|
case ESettingsWindowNames::Run:
|
|
|
|
return "Run";
|
|
|
|
case ESettingsWindowNames::ImageResizer:
|
|
|
|
return "ImageResizer";
|
|
|
|
case ESettingsWindowNames::KBM:
|
|
|
|
return "KBM";
|
2021-10-22 13:30:18 +01:00
|
|
|
case ESettingsWindowNames::MouseUtils:
|
|
|
|
return "MouseUtils";
|
2021-09-29 12:54:05 +02:00
|
|
|
case ESettingsWindowNames::PowerRename:
|
|
|
|
return "PowerRename";
|
|
|
|
case ESettingsWindowNames::FileExplorer:
|
|
|
|
return "FileExplorer";
|
|
|
|
case ESettingsWindowNames::ShortcutGuide:
|
|
|
|
return "ShortcutGuide";
|
|
|
|
case ESettingsWindowNames::VideoConference:
|
|
|
|
return "VideoConference";
|
2022-10-13 13:05:43 +02:00
|
|
|
case ESettingsWindowNames::Hosts:
|
|
|
|
return "Hosts";
|
Registry Preview: complete feature with integration with Settings and the Launcher UX (#23709)
* Initial src for Registry Preview
Initial collection of files
* Update MainWindow.Utilities.cs
fixing a few spelling items
* Update expect.txt
* Update App.xaml.cs
* Update MainWindow.Events.cs
* Update MainWindow.Utilities.cs
* Update MainWindow.xaml.cs
* Update expect.txt
* Update MainWindow.Events.cs
* Rename AddPreviewtoRegfile.reg to AddPreviewToRegfile.reg
* Rename RemovePreviewtoRegfile.reg to RemovePreviewToRegfile.reg
* Update Resources.resw
* Update MainWindow.xaml
* Turns on self-contained mode
Updates the csproj file to compile the app as self-contained .
Includes fixes for code that expected the app to be in an ApplicationContainer.
Updates WindowsAppSDK from 1.1.5 to 1.2.230118.102.
* Updated to align with StyleCop errors
Multiple changes across the codebase that now aligns with StyleCop guidelines.
Tested again after the changes, to make sure no new bugs crept in.
* Added comments for spell-checker
Unclear if this side step should be done or not, but the kxz comes from a GUID and the other three names are constants.
* Adding code-custom.dic
Comments didn't work; trying a dic file
* Added four new terms to expects.txt file
Cleaning up attempt to update the spell-checker with dic file and moved it to expects.txt file
* Adding one more string
Adding one more string for Spell-Check
* Adding back egfile
Seems this is needed.
* Correcting a variable name
Seems one of the variable names that changed globally got missed in a XAML file.
* Update project to be more PowerToys friendly
Tweaking names and output file name to fit better with PowerToys.
* First pass at integration into Settings and Launcher
This PR is not as large as it seems:
- RegistryPreview's source moved around to a "better" directory that makes it look like the whole app changed. It didn't. In fact, I opened it in Beyond Compare and there's not much difference in the RegistryPreview app.
- Added RegistryPreviewExt that produces a DLL that the Launcher can run the EXE
- Changes to Runner calls the Ext DLL rather than the app
- Settings UI got a bunch of changes to enable the Settings page for enable/disable across ViewModels, Views, and string tables.
Still todo:
- Add "Preview" to .REG files, when the app is enable (and remove it when disabled)
- Update the thumbnail-screenshot in the Settings page
- Add support for OOBE
* Update expect.txt
Added REGISTRYPREVIEWEXT for recent changes and corrected an alphabetic sorting error.
* Updating project file for Release mode
Build failed due to a bad Includes path in Release mode.
* Adds REG registration but breaks settings
This update will update the HKCU branch of the Registry for REG files: if the app in PowerToys is enabled, it adds a Preview item to the context menu of REG files and disabling in PowerToys removes the menu item.
While working on this, I noticed that the application settings were broken, after moving to a self-contained EXE: there must have been old settings from past builds, when it was still using containers and family names.
Added TODO's to add a new way to save settings, likely as JSON.
* Re-enabled app settings
Moved from using ApplicationDataContainer for app settings and now use simple JSON.
Also cleaned up handling the scenario where the Launcher send in the PID from PowerToys' main thread.
Fixed past spelling errors as well.
* Update RegistryPreview.png
Captured new screenshot.
* Integration into OOBE
Integrates new page for Registry Preview into OOBE process.
* Removing old comment and unneeded calls
Two bits of source removed as they aren't needed any longer
Removing a chunk of old commented out code that doesn't make sense anymore.
* Merging file from upstream
Updating some files due to three merge conflicts from upstream changes and a couple of other changes to keep up.
* Update .gitignore
Adding two vcxproj files that have local updates for atls.lib locations.
* Update Resources.resw
Fixing a typo that involved a missing closing tag.
* Fix analyzer warnings
* Fix CI build
* Fix ARM64 build
Project file cleanup
* Add to installer
* expect.txt
* Remove unneeded dll
* Update MainWindow.xaml.cs
Added check for current Theme and adjust TextBox Foreground accordingly.
* Update expect.txt
Cleaning up merge cruft.
* Revert wrong .gitignore changes
* Fix ARM installer
* Update Brushes for textBox to use Theme based versions
Finally figured out how to use the built-in, Theme-aware Brushes for the font colors in the onscreen textBox. Also have it aligning the font color for the hover state.
* Align configuration in PowerToys.sln
* [installer] Add missing files
* Fix bad merge
* Fixes for stefansjfw's review
Includes:
- two new strings for UX localization
- adds compatibility section for Windows 10
- fix to only track successful activations
- Removes two REG files that were there for examples
* Fixes from review from htcfreek
Updates:
- Fixed an issue where TextBox_TextChanged was firing when you simply opened a file.
- Added clamp to prevent files larger than 10MB from being opened.
- Added support in the UX to show Keys and Values that are deleted via the file
- Added support to specially handle Keys that start with - and Values that have =- in them (delete scenario)
- Changed AppBarButton icon for Edit from Rename to NewWindow
* Create deleted-folder32.png
* Added Registry Preview to GPO
* Update expect.txt
Updating spellchecker works
* Updating Size/Move code for better results
- Moved the size/move to the MainWindow layer
- Cleaned up the JSON settings handling to avoid an access denied on first run
* Improving text handling
Changed how special characters are parse, which helps with live entry.
* Updates to parsing and other fixes
- Renamed the value PNG for parity
- Added new error image
- Added check that values have " at start and finish.
- Added support for a new "ERROR" type for Values
- Fixed support for @ versus "@" in values
- Fixed bug where Save wasn't activating in all scernarios
* Fix signing and versioning
* Update src/settings-ui/Settings.UI/ViewModels/RegistryPreviewViewModel.cs
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Apply suggestions from code review
Adds Launch button to the settings page.
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Update Resources.resw
Adding strings for new launch button
* Adding new version for GPO
Moving to 0.69.0
* More parsing bug fixes
- Changes to look for [- instead of -[ for syntax deleting keys (fix for developer's mental hiccup)
- Moved [- to top of the decision making stack, as it needs to come before [
- Added new StripEscapedCharacters function for both sides of a Value line
- Fixed crashing bug for scenario where no Keys are parsed before a Value
* Bug fixes from most recent review.
- Dictionary will now be case insensitive when searching for keys
- Added tool tips (and strings) to the images of the Keys and Values
- Updated delete handling for Keys, so that only the leaf-most node gets marked as deleted; also stops the top most roots from being marked deleted.
* Tweaking for @=-
Forces the UX to take @=- and treat it as @="" since that's what Registry Editor would do.
* Removing unused usings
* Updates app description
* Update src/gpo/assets/PowerToys.admx
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* cleanup proj file
launch process only if module is enabled
add process to bugreport process list
* Add context menu icon
* Update src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Use modulesRegistry.h to apply/unapply registry changes
* Tweaked window settings
Moved the loading of the settings a little later in the initialization code, which gives more time for things to initialize.
* Update registry.h
Moving the definition out of the detail namespace to the registry name space to fix a compilation issue in RegistryPreviewExt.
* Unapply on creation
If module is disabled in settings.json, on startup reg entries should be unnaplied.
TODO: read m_enabled from settings file on creation
* Removing size/move main window
Added a TODO comment that responds to the size/position settings that are being saved out in the JSON blob on close as it doesn't always work on every PC, as the MainWindow initializes at different times.
* Change to always keep Save As active
No reason for this to be disabled, honestly.
---------
Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
2023-03-27 06:21:46 -07:00
|
|
|
case ESettingsWindowNames::RegistryPreview:
|
|
|
|
return "RegistryPreview";
|
2021-09-29 12:54:05 +02:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
Logger::error(L"Can't convert ESettingsWindowNames value={} to string", static_cast<int>(value));
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
ESettingsWindowNames ESettingsWindowNames_from_string(std::string value)
|
|
|
|
{
|
|
|
|
if (value == "Overview")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::Overview;
|
|
|
|
}
|
|
|
|
else if (value == "Awake")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::Awake;
|
|
|
|
}
|
|
|
|
else if (value == "ColorPicker")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::ColorPicker;
|
|
|
|
}
|
|
|
|
else if (value == "FancyZones")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::FancyZones;
|
|
|
|
}
|
|
|
|
else if (value == "Run")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::Run;
|
|
|
|
}
|
|
|
|
else if (value == "ImageResizer")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::ImageResizer;
|
|
|
|
}
|
|
|
|
else if (value == "KBM")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::KBM;
|
|
|
|
}
|
2021-10-22 13:30:18 +01:00
|
|
|
else if (value == "MouseUtils")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::MouseUtils;
|
|
|
|
}
|
2021-09-29 12:54:05 +02:00
|
|
|
else if (value == "PowerRename")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::PowerRename;
|
|
|
|
}
|
|
|
|
else if (value == "FileExplorer")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::FileExplorer;
|
|
|
|
}
|
|
|
|
else if (value == "ShortcutGuide")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::ShortcutGuide;
|
|
|
|
}
|
|
|
|
else if (value == "VideoConference")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::VideoConference;
|
|
|
|
}
|
2022-10-13 13:05:43 +02:00
|
|
|
else if (value == "Hosts")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::Hosts;
|
|
|
|
}
|
Registry Preview: complete feature with integration with Settings and the Launcher UX (#23709)
* Initial src for Registry Preview
Initial collection of files
* Update MainWindow.Utilities.cs
fixing a few spelling items
* Update expect.txt
* Update App.xaml.cs
* Update MainWindow.Events.cs
* Update MainWindow.Utilities.cs
* Update MainWindow.xaml.cs
* Update expect.txt
* Update MainWindow.Events.cs
* Rename AddPreviewtoRegfile.reg to AddPreviewToRegfile.reg
* Rename RemovePreviewtoRegfile.reg to RemovePreviewToRegfile.reg
* Update Resources.resw
* Update MainWindow.xaml
* Turns on self-contained mode
Updates the csproj file to compile the app as self-contained .
Includes fixes for code that expected the app to be in an ApplicationContainer.
Updates WindowsAppSDK from 1.1.5 to 1.2.230118.102.
* Updated to align with StyleCop errors
Multiple changes across the codebase that now aligns with StyleCop guidelines.
Tested again after the changes, to make sure no new bugs crept in.
* Added comments for spell-checker
Unclear if this side step should be done or not, but the kxz comes from a GUID and the other three names are constants.
* Adding code-custom.dic
Comments didn't work; trying a dic file
* Added four new terms to expects.txt file
Cleaning up attempt to update the spell-checker with dic file and moved it to expects.txt file
* Adding one more string
Adding one more string for Spell-Check
* Adding back egfile
Seems this is needed.
* Correcting a variable name
Seems one of the variable names that changed globally got missed in a XAML file.
* Update project to be more PowerToys friendly
Tweaking names and output file name to fit better with PowerToys.
* First pass at integration into Settings and Launcher
This PR is not as large as it seems:
- RegistryPreview's source moved around to a "better" directory that makes it look like the whole app changed. It didn't. In fact, I opened it in Beyond Compare and there's not much difference in the RegistryPreview app.
- Added RegistryPreviewExt that produces a DLL that the Launcher can run the EXE
- Changes to Runner calls the Ext DLL rather than the app
- Settings UI got a bunch of changes to enable the Settings page for enable/disable across ViewModels, Views, and string tables.
Still todo:
- Add "Preview" to .REG files, when the app is enable (and remove it when disabled)
- Update the thumbnail-screenshot in the Settings page
- Add support for OOBE
* Update expect.txt
Added REGISTRYPREVIEWEXT for recent changes and corrected an alphabetic sorting error.
* Updating project file for Release mode
Build failed due to a bad Includes path in Release mode.
* Adds REG registration but breaks settings
This update will update the HKCU branch of the Registry for REG files: if the app in PowerToys is enabled, it adds a Preview item to the context menu of REG files and disabling in PowerToys removes the menu item.
While working on this, I noticed that the application settings were broken, after moving to a self-contained EXE: there must have been old settings from past builds, when it was still using containers and family names.
Added TODO's to add a new way to save settings, likely as JSON.
* Re-enabled app settings
Moved from using ApplicationDataContainer for app settings and now use simple JSON.
Also cleaned up handling the scenario where the Launcher send in the PID from PowerToys' main thread.
Fixed past spelling errors as well.
* Update RegistryPreview.png
Captured new screenshot.
* Integration into OOBE
Integrates new page for Registry Preview into OOBE process.
* Removing old comment and unneeded calls
Two bits of source removed as they aren't needed any longer
Removing a chunk of old commented out code that doesn't make sense anymore.
* Merging file from upstream
Updating some files due to three merge conflicts from upstream changes and a couple of other changes to keep up.
* Update .gitignore
Adding two vcxproj files that have local updates for atls.lib locations.
* Update Resources.resw
Fixing a typo that involved a missing closing tag.
* Fix analyzer warnings
* Fix CI build
* Fix ARM64 build
Project file cleanup
* Add to installer
* expect.txt
* Remove unneeded dll
* Update MainWindow.xaml.cs
Added check for current Theme and adjust TextBox Foreground accordingly.
* Update expect.txt
Cleaning up merge cruft.
* Revert wrong .gitignore changes
* Fix ARM installer
* Update Brushes for textBox to use Theme based versions
Finally figured out how to use the built-in, Theme-aware Brushes for the font colors in the onscreen textBox. Also have it aligning the font color for the hover state.
* Align configuration in PowerToys.sln
* [installer] Add missing files
* Fix bad merge
* Fixes for stefansjfw's review
Includes:
- two new strings for UX localization
- adds compatibility section for Windows 10
- fix to only track successful activations
- Removes two REG files that were there for examples
* Fixes from review from htcfreek
Updates:
- Fixed an issue where TextBox_TextChanged was firing when you simply opened a file.
- Added clamp to prevent files larger than 10MB from being opened.
- Added support in the UX to show Keys and Values that are deleted via the file
- Added support to specially handle Keys that start with - and Values that have =- in them (delete scenario)
- Changed AppBarButton icon for Edit from Rename to NewWindow
* Create deleted-folder32.png
* Added Registry Preview to GPO
* Update expect.txt
Updating spellchecker works
* Updating Size/Move code for better results
- Moved the size/move to the MainWindow layer
- Cleaned up the JSON settings handling to avoid an access denied on first run
* Improving text handling
Changed how special characters are parse, which helps with live entry.
* Updates to parsing and other fixes
- Renamed the value PNG for parity
- Added new error image
- Added check that values have " at start and finish.
- Added support for a new "ERROR" type for Values
- Fixed support for @ versus "@" in values
- Fixed bug where Save wasn't activating in all scernarios
* Fix signing and versioning
* Update src/settings-ui/Settings.UI/ViewModels/RegistryPreviewViewModel.cs
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Apply suggestions from code review
Adds Launch button to the settings page.
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Update Resources.resw
Adding strings for new launch button
* Adding new version for GPO
Moving to 0.69.0
* More parsing bug fixes
- Changes to look for [- instead of -[ for syntax deleting keys (fix for developer's mental hiccup)
- Moved [- to top of the decision making stack, as it needs to come before [
- Added new StripEscapedCharacters function for both sides of a Value line
- Fixed crashing bug for scenario where no Keys are parsed before a Value
* Bug fixes from most recent review.
- Dictionary will now be case insensitive when searching for keys
- Added tool tips (and strings) to the images of the Keys and Values
- Updated delete handling for Keys, so that only the leaf-most node gets marked as deleted; also stops the top most roots from being marked deleted.
* Tweaking for @=-
Forces the UX to take @=- and treat it as @="" since that's what Registry Editor would do.
* Removing unused usings
* Updates app description
* Update src/gpo/assets/PowerToys.admx
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* cleanup proj file
launch process only if module is enabled
add process to bugreport process list
* Add context menu icon
* Update src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
* Use modulesRegistry.h to apply/unapply registry changes
* Tweaked window settings
Moved the loading of the settings a little later in the initialization code, which gives more time for things to initialize.
* Update registry.h
Moving the definition out of the detail namespace to the registry name space to fix a compilation issue in RegistryPreviewExt.
* Unapply on creation
If module is disabled in settings.json, on startup reg entries should be unnaplied.
TODO: read m_enabled from settings file on creation
* Removing size/move main window
Added a TODO comment that responds to the size/position settings that are being saved out in the JSON blob on close as it doesn't always work on every PC, as the MainWindow initializes at different times.
* Change to always keep Save As active
No reason for this to be disabled, honestly.
---------
Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
2023-03-27 06:21:46 -07:00
|
|
|
else if (value == "RegistryPreview")
|
|
|
|
{
|
|
|
|
return ESettingsWindowNames::RegistryPreview;
|
|
|
|
}
|
2021-09-29 12:54:05 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Logger::error(L"Can't convert string value={} to ESettingsWindowNames", winrt::to_hstring(value));
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ESettingsWindowNames::Overview;
|
|
|
|
}
|