diff --git a/src/common/interop/shared_constants.h b/src/common/interop/shared_constants.h index aa6306d7ba..c8a02be901 100644 --- a/src/common/interop/shared_constants.h +++ b/src/common/interop/shared_constants.h @@ -83,6 +83,11 @@ namespace CommonSharedConstants const wchar_t TERMINATE_MOUSE_JUMP_SHARED_EVENT[] = L"Local\\TerminateMouseJumpEvent-252fa337-317f-4c37-a61f-99464c3f9728"; + // Paths to the events used by other Mouse Utilities + const wchar_t FIND_MY_MOUSE_TRIGGER_EVENT[] = L"Local\\FindMyMouseTriggerEvent-5a9dc5f4-1c74-4f2f-a66f-1b9b6a2f9b23"; + const wchar_t MOUSE_HIGHLIGHTER_TRIGGER_EVENT[] = L"Local\\MouseHighlighterTriggerEvent-1e3c9c3d-3fdf-4f9a-9a52-31c9b3c3a8f4"; + const wchar_t MOUSE_CROSSHAIRS_TRIGGER_EVENT[] = L"Local\\MouseCrosshairsTriggerEvent-0d4c7f92-0a5c-4f5c-b64b-8a2a2f7e0b21"; + // Path to the event used by RegistryPreview const wchar_t REGISTRY_PREVIEW_TRIGGER_EVENT[] = L"Local\\RegistryPreviewEvent-4C559468-F75A-4E7F-BC4F-9C9688316687"; diff --git a/src/common/utils/process_path.h b/src/common/utils/process_path.h index 56129a9bb7..785883d984 100644 --- a/src/common/utils/process_path.h +++ b/src/common/utils/process_path.h @@ -3,6 +3,8 @@ #include #include +#pragma comment(lib, "Shlwapi.lib") + #include #include diff --git a/src/modules/MouseUtils/FindMyMouse/dllmain.cpp b/src/modules/MouseUtils/FindMyMouse/dllmain.cpp index b7ffb6177a..18c368d407 100644 --- a/src/modules/MouseUtils/FindMyMouse/dllmain.cpp +++ b/src/modules/MouseUtils/FindMyMouse/dllmain.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include namespace { @@ -69,6 +71,12 @@ private: // Find My Mouse specific settings FindMyMouseSettings m_findMyMouseSettings; + // Event-driven trigger support + HANDLE m_triggerEventHandle = nullptr; + HANDLE m_terminateEventHandle = nullptr; + std::thread m_eventThread; + std::atomic_bool m_listening{ false }; + // Load initial settings from the persisted values. void init_settings(); @@ -150,6 +158,34 @@ public: m_enabled = true; Trace::EnableFindMyMouse(true); std::thread([=]() { FindMyMouseMain(m_hModule, m_findMyMouseSettings); }).detach(); + + // Start listening for external trigger event so we can invoke the same logic as the hotkey. + m_triggerEventHandle = CreateEventW(nullptr, false, false, CommonSharedConstants::FIND_MY_MOUSE_TRIGGER_EVENT); + m_terminateEventHandle = CreateEventW(nullptr, false, false, nullptr); + if (m_triggerEventHandle && m_terminateEventHandle) + { + m_listening = true; + m_eventThread = std::thread([this]() { + HANDLE handles[2] = { m_triggerEventHandle, m_terminateEventHandle }; + while (m_listening) + { + auto res = WaitForMultipleObjects(2, handles, false, INFINITE); + if (!m_listening) + { + break; + } + + if (res == WAIT_OBJECT_0) + { + OnHotkeyEx(); + } + else + { + break; + } + } + }); + } } // Disable the powertoy @@ -158,6 +194,26 @@ public: m_enabled = false; Trace::EnableFindMyMouse(false); FindMyMouseDisable(); + + m_listening = false; + if (m_terminateEventHandle) + { + SetEvent(m_terminateEventHandle); + } + if (m_eventThread.joinable()) + { + m_eventThread.join(); + } + if (m_triggerEventHandle) + { + CloseHandle(m_triggerEventHandle); + m_triggerEventHandle = nullptr; + } + if (m_terminateEventHandle) + { + CloseHandle(m_terminateEventHandle); + m_terminateEventHandle = nullptr; + } } // Returns if the powertoys is enabled @@ -216,7 +272,7 @@ inline static uint8_t LegacyOpacityToAlpha(int overlayOpacityPercent) overlayOpacityPercent = 100; } - // Round to nearest integer (0–255) + // Round to nearest integer (0–255) return static_cast((overlayOpacityPercent * 255 + 50) / 100); } @@ -532,4 +588,4 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings) extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() { return new FindMyMouse(); -} \ No newline at end of file +} diff --git a/src/modules/MouseUtils/MouseHighlighter/dllmain.cpp b/src/modules/MouseUtils/MouseHighlighter/dllmain.cpp index 45c62ae9ca..b5580a3651 100644 --- a/src/modules/MouseUtils/MouseHighlighter/dllmain.cpp +++ b/src/modules/MouseUtils/MouseHighlighter/dllmain.cpp @@ -4,6 +4,8 @@ #include "trace.h" #include "MouseHighlighter.h" #include "common/utils/color.h" +#include +#include namespace { @@ -61,6 +63,12 @@ private: // Mouse Highlighter specific settings MouseHighlighterSettings m_highlightSettings; + // Event-driven trigger support + HANDLE m_triggerEventHandle = nullptr; + HANDLE m_terminateEventHandle = nullptr; + std::thread m_eventThread; + std::atomic_bool m_listening{ false }; + public: // Constructor MouseHighlighter() @@ -132,6 +140,34 @@ public: m_enabled = true; Trace::EnableMouseHighlighter(true); std::thread([=]() { MouseHighlighterMain(m_hModule, m_highlightSettings); }).detach(); + + // Start listening for external trigger event so we can invoke the same logic as the hotkey. + m_triggerEventHandle = CreateEventW(nullptr, false, false, CommonSharedConstants::MOUSE_HIGHLIGHTER_TRIGGER_EVENT); + m_terminateEventHandle = CreateEventW(nullptr, false, false, nullptr); + if (m_triggerEventHandle && m_terminateEventHandle) + { + m_listening = true; + m_eventThread = std::thread([this]() { + HANDLE handles[2] = { m_triggerEventHandle, m_terminateEventHandle }; + while (m_listening) + { + auto res = WaitForMultipleObjects(2, handles, false, INFINITE); + if (!m_listening) + { + break; + } + + if (res == WAIT_OBJECT_0) + { + OnHotkeyEx(); + } + else + { + break; + } + } + }); + } } // Disable the powertoy @@ -140,6 +176,26 @@ public: m_enabled = false; Trace::EnableMouseHighlighter(false); MouseHighlighterDisable(); + + m_listening = false; + if (m_terminateEventHandle) + { + SetEvent(m_terminateEventHandle); + } + if (m_eventThread.joinable()) + { + m_eventThread.join(); + } + if (m_triggerEventHandle) + { + CloseHandle(m_triggerEventHandle); + m_triggerEventHandle = nullptr; + } + if (m_terminateEventHandle) + { + CloseHandle(m_terminateEventHandle); + m_terminateEventHandle = nullptr; + } } // Returns if the powertoys is enabled diff --git a/src/modules/MouseUtils/MousePointerCrosshairs/dllmain.cpp b/src/modules/MouseUtils/MousePointerCrosshairs/dllmain.cpp index b460e29643..dfdbc2d4e7 100644 --- a/src/modules/MouseUtils/MousePointerCrosshairs/dllmain.cpp +++ b/src/modules/MouseUtils/MousePointerCrosshairs/dllmain.cpp @@ -4,6 +4,7 @@ #include "trace.h" #include "InclusiveCrosshairs.h" #include "common/utils/color.h" +#include #include #include #include @@ -124,6 +125,12 @@ private: // Mouse Pointer Crosshairs specific settings InclusiveCrosshairsSettings m_inclusiveCrosshairsSettings; + // Event-driven trigger support + HANDLE m_triggerEventHandle = nullptr; + HANDLE m_terminateEventHandle = nullptr; + std::thread m_eventThread; + std::atomic_bool m_listening{ false }; + public: // Constructor MousePointerCrosshairs() @@ -203,6 +210,34 @@ public: m_enabled = true; Trace::EnableMousePointerCrosshairs(true); std::thread([=]() { InclusiveCrosshairsMain(m_hModule, m_inclusiveCrosshairsSettings); }).detach(); + + // Start listening for external trigger event so we can invoke the same logic as the activation hotkey. + m_triggerEventHandle = CreateEventW(nullptr, false, false, CommonSharedConstants::MOUSE_CROSSHAIRS_TRIGGER_EVENT); + m_terminateEventHandle = CreateEventW(nullptr, false, false, nullptr); + if (m_triggerEventHandle && m_terminateEventHandle) + { + m_listening = true; + m_eventThread = std::thread([this]() { + HANDLE handles[2] = { m_triggerEventHandle, m_terminateEventHandle }; + while (m_listening) + { + auto res = WaitForMultipleObjects(2, handles, false, INFINITE); + if (!m_listening) + { + break; + } + + if (res == WAIT_OBJECT_0) + { + on_hotkey(0); // activation hotkey + } + else + { + break; + } + } + }); + } } // Disable the powertoy @@ -215,6 +250,26 @@ public: StopYTimer(); m_glideState = 0; InclusiveCrosshairsDisable(); + + m_listening = false; + if (m_terminateEventHandle) + { + SetEvent(m_terminateEventHandle); + } + if (m_eventThread.joinable()) + { + m_eventThread.join(); + } + if (m_triggerEventHandle) + { + CloseHandle(m_triggerEventHandle); + m_triggerEventHandle = nullptr; + } + if (m_terminateEventHandle) + { + CloseHandle(m_terminateEventHandle); + m_terminateEventHandle = nullptr; + } } // Returns if the powertoys is enabled @@ -901,4 +956,4 @@ private: extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() { return new MousePointerCrosshairs(); -} \ No newline at end of file +} diff --git a/src/modules/ZoomIt/ZoomIt/ZoomIt.vcxproj b/src/modules/ZoomIt/ZoomIt/ZoomIt.vcxproj index b1f91a5228..4e19cda505 100644 --- a/src/modules/ZoomIt/ZoomIt/ZoomIt.vcxproj +++ b/src/modules/ZoomIt/ZoomIt/ZoomIt.vcxproj @@ -241,6 +241,7 @@ NotUsing + Use @@ -296,6 +297,8 @@ + + @@ -369,4 +372,4 @@ - \ No newline at end of file + diff --git a/src/modules/ZoomIt/ZoomIt/ZoomItIpc.cpp b/src/modules/ZoomIt/ZoomIt/ZoomItIpc.cpp new file mode 100644 index 0000000000..4959f990c5 --- /dev/null +++ b/src/modules/ZoomIt/ZoomIt/ZoomItIpc.cpp @@ -0,0 +1,160 @@ +#include "pch.h" +#include "ZoomItIpc.h" + +#include +#include +#include +#include + +using namespace std::literals; + +namespace ZoomItIpc +{ + namespace + { + Command FromString(const std::string& action) + { + if (action == "zoom") + return Command::Zoom; + if (action == "draw") + return Command::Draw; + if (action == "break") + return Command::Break; + if (action == "livezoom") + return Command::LiveZoom; + if (action == "snip") + return Command::Snip; + if (action == "record") + return Command::Record; + return Command::Unknown; + } + + Command ParseJson(const std::string& json) + { + // Very small parse: look for "action":"" + auto pos = json.find("\"action\""); + if (pos == std::string::npos) + return Command::Unknown; + + pos = json.find(':', pos); + if (pos == std::string::npos) + return Command::Unknown; + + pos = json.find('"', pos); + if (pos == std::string::npos) + return Command::Unknown; + + auto end = json.find('"', pos + 1); + if (end == std::string::npos || end <= pos + 1) + return Command::Unknown; + + auto value = json.substr(pos + 1, end - pos - 1); + // normalize to lowercase + std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c) { return static_cast(std::tolower(static_cast(c))); }); + return FromString(value); + } + + bool ReadPayload(HANDLE pipe, std::string& outPayload) + { + DWORD bytesRead = 0; + char buffer[512] = {}; + if (!ReadFile(pipe, buffer, static_cast(sizeof(buffer) - 1), &bytesRead, nullptr) || bytesRead == 0) + { + return false; + } + + buffer[bytesRead] = '\0'; + outPayload.assign(buffer, bytesRead); + return true; + } + } // namespace + + Command ParseCommand(const std::string& payloadUtf8) + { + return ParseJson(payloadUtf8); + } + + // ZoomIt.exe will call this; needs to hook into action dispatcher externally. + bool RunServer() + { + std::thread([]() { + for (;;) + { + auto hPipe = CreateNamedPipeW( + PIPE_NAME, + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + 1, + 1024, + 1024, + 0, + nullptr); + + if (hPipe == INVALID_HANDLE_VALUE) + { + break; + } + + if (!ConnectNamedPipe(hPipe, nullptr)) + { + CloseHandle(hPipe); + continue; + } + + std::string payload; + if (ReadPayload(hPipe, payload)) + { + auto cmd = ParseCommand(payload); + // Dispatch hook implemented elsewhere in ZoomIt.exe + extern void ZoomIt_DispatchCommand(Command cmd); + ZoomIt_DispatchCommand(cmd); + } + + DisconnectNamedPipe(hPipe); + CloseHandle(hPipe); + } + }).detach(); + + return true; + } + + bool SendCommand(Command cmd) + { + auto hPipe = CreateFileW(PIPE_NAME, GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); + if (hPipe == INVALID_HANDLE_VALUE) + { + return false; + } + + const char* action = "unknown"; + switch (cmd) + { + case Command::Zoom: + action = "zoom"; + break; + case Command::Draw: + action = "draw"; + break; + case Command::Break: + action = "break"; + break; + case Command::LiveZoom: + action = "livezoom"; + break; + case Command::Snip: + action = "snip"; + break; + case Command::Record: + action = "record"; + break; + default: + break; + } + + auto payload = std::format("{{\"action\":\"{}\"}}", action); + DWORD written = 0; + const bool ok = WriteFile(hPipe, payload.data(), static_cast(payload.size()), &written, nullptr); + CloseHandle(hPipe); + return ok && written == payload.size(); + } +} // namespace ZoomItIpc diff --git a/src/modules/ZoomIt/ZoomIt/ZoomItIpc.h b/src/modules/ZoomIt/ZoomIt/ZoomItIpc.h new file mode 100644 index 0000000000..84d1ecaa7c --- /dev/null +++ b/src/modules/ZoomIt/ZoomIt/ZoomItIpc.h @@ -0,0 +1,30 @@ +// 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. + +#pragma once + +#include + +namespace ZoomItIpc +{ + inline constexpr wchar_t PIPE_NAME[] = L"\\\\.\\pipe\\powertoys_zoomit_cmd"; + + enum class Command + { + Unknown = 0, + Zoom, + Draw, + Break, + LiveZoom, + Snip, + Record, + }; + + // Simple UTF-8 JSON payload: { "action": "" } + Command ParseCommand(const std::string& payloadUtf8); + + bool RunServer(); + + bool SendCommand(Command cmd); +} // namespace ZoomItIpc diff --git a/src/modules/ZoomIt/ZoomIt/Zoomit.cpp b/src/modules/ZoomIt/ZoomIt/Zoomit.cpp index 71f09fc578..ef942f24ae 100644 --- a/src/modules/ZoomIt/ZoomIt/Zoomit.cpp +++ b/src/modules/ZoomIt/ZoomIt/Zoomit.cpp @@ -16,6 +16,9 @@ #include "WindowsVersions.h" #include "ZoomItSettings.h" #include "GifRecordingSession.h" +#include "ZoomItIpc.h" +#include "zoomit_mode.h" +#include "zoomit_mode.h" #ifdef __ZOOMIT_POWERTOYS__ #include @@ -172,7 +175,6 @@ std::wstring g_RecordingSaveLocationGIF; winrt::IDirect3DDevice g_RecordDevice{ nullptr }; std::shared_ptr g_RecordingSession = nullptr; std::shared_ptr g_GifRecordingSession = nullptr; - type_pGetMonitorInfo pGetMonitorInfo; type_MonitorFromPoint pMonitorFromPoint; type_pSHAutoComplete pSHAutoComplete; @@ -7712,6 +7714,50 @@ HWND InitInstance( HINSTANCE hInstance, int nCmdShow ) } +// Dispatch commands coming from the PowerToys IPC channel. +#ifdef __ZOOMIT_POWERTOYS__ +void ZoomIt_DispatchCommand(ZoomItIpc::Command cmd) +{ + auto post_hotkey = [](WPARAM id) + { + if (g_hWndMain != nullptr) + { + PostMessage(g_hWndMain, WM_HOTKEY, id, 0); + } + }; + + switch (cmd) + { + case ZoomItIpc::Command::Zoom: + post_hotkey(ZOOM_HOTKEY); + Trace::ZoomItActivateZoom(); + break; + case ZoomItIpc::Command::Draw: + post_hotkey(DRAW_HOTKEY); + Trace::ZoomItActivateDraw(); + break; + case ZoomItIpc::Command::Break: + post_hotkey(BREAK_HOTKEY); + Trace::ZoomItActivateBreak(); + break; + case ZoomItIpc::Command::LiveZoom: + post_hotkey(LIVE_HOTKEY); + Trace::ZoomItActivateLiveZoom(); + break; + case ZoomItIpc::Command::Snip: + post_hotkey(SNIP_HOTKEY); + Trace::ZoomItActivateSnip(); + break; + case ZoomItIpc::Command::Record: + post_hotkey(RECORD_HOTKEY); + Trace::ZoomItActivateRecord(); + break; + default: + break; + } +} +#endif + //---------------------------------------------------------------------------- // // WinMain @@ -7746,6 +7792,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance // Initialize logger LoggerHelpers::init_logger(L"ZoomIt", L"", LogSettings::zoomItLoggerName); + ZoomItIpc::RunServer(); ProcessWaiter::OnProcessTerminate(pid, [mainThreadId](int err) { if (err != ERROR_SUCCESS) @@ -7986,3 +8033,4 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance return retCode; } +#include "zoomit_mode.h" diff --git a/src/modules/ZoomIt/ZoomIt/zoomit_mode.h b/src/modules/ZoomIt/ZoomIt/zoomit_mode.h new file mode 100644 index 0000000000..0f759d1fa7 --- /dev/null +++ b/src/modules/ZoomIt/ZoomIt/zoomit_mode.h @@ -0,0 +1,7 @@ +// ZoomIt mode ids (map to WM_HOTKEY wParam values) +#define ZOOM_MODE_ID_ZOOM 0 +#define ZOOM_MODE_ID_DRAW 1 +#define ZOOM_MODE_ID_BREAK 2 +#define ZOOM_MODE_ID_LIVEZOOM 3 +#define ZOOM_MODE_ID_RECORD 5 +#define ZOOM_MODE_ID_SNIP 8 diff --git a/src/modules/ZoomIt/ZoomItModuleInterface/dllmain.cpp b/src/modules/ZoomIt/ZoomItModuleInterface/dllmain.cpp index eea809a0a2..40158ed68f 100644 --- a/src/modules/ZoomIt/ZoomItModuleInterface/dllmain.cpp +++ b/src/modules/ZoomIt/ZoomItModuleInterface/dllmain.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockReparentCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockReparentCommand.cs new file mode 100644 index 0000000000..be988f554c --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockReparentCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Triggers Crop and Lock reparent mode via the shared event. +/// +internal sealed partial class CropAndLockReparentCommand : InvokableCommand +{ + public CropAndLockReparentCommand() + { + Name = "Crop and Lock (Reparent)"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.CropAndLockReparent); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to start Crop and Lock (Reparent): {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockThumbnailCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockThumbnailCommand.cs new file mode 100644 index 0000000000..ddb28d9fd7 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/CropAndLock/CropAndLockThumbnailCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Triggers Crop and Lock thumbnail mode via the shared event. +/// +internal sealed partial class CropAndLockThumbnailCommand : InvokableCommand +{ + public CropAndLockThumbnailCommand() + { + Name = "Crop and Lock (Thumbnail)"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.CropAndLockThumbnail); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to start Crop and Lock (Thumbnail): {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesAdminCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesAdminCommand.cs new file mode 100644 index 0000000000..e2679ffaf5 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesAdminCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches Environment Variables (admin) via the shared event. +/// +internal sealed partial class OpenEnvironmentVariablesAdminCommand : InvokableCommand +{ + public OpenEnvironmentVariablesAdminCommand() + { + Name = "Open Environment Variables (Admin)"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.EnvironmentVariablesShowAdmin); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open Environment Variables (Admin): {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesCommand.cs new file mode 100644 index 0000000000..680a403696 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/EnvironmentVariables/OpenEnvironmentVariablesCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches Environment Variables (user) via the shared event. +/// +internal sealed partial class OpenEnvironmentVariablesCommand : InvokableCommand +{ + public OpenEnvironmentVariablesCommand() + { + Name = "Open Environment Variables"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.EnvironmentVariablesShow); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open Environment Variables: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/FancyZones/OpenFancyZonesEditorCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/FancyZones/OpenFancyZonesEditorCommand.cs new file mode 100644 index 0000000000..fd6811dc8a --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/FancyZones/OpenFancyZonesEditorCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches the FancyZones layout editor via the shared event. +/// +internal sealed partial class OpenFancyZonesEditorCommand : InvokableCommand +{ + public OpenFancyZonesEditorCommand() + { + Name = "Open FancyZones Editor"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.FancyZonesToggleEditor); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open FancyZones editor: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorAdminCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorAdminCommand.cs new file mode 100644 index 0000000000..167ebe1e95 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorAdminCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches Hosts File Editor (Admin) via the shared event. +/// +internal sealed partial class OpenHostsEditorAdminCommand : InvokableCommand +{ + public OpenHostsEditorAdminCommand() + { + Name = "Open Hosts File Editor (Admin)"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.HostsShowAdmin); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open Hosts File Editor (Admin): {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorCommand.cs new file mode 100644 index 0000000000..0f10e96e4e --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/Hosts/OpenHostsEditorCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches Hosts File Editor via the shared event. +/// +internal sealed partial class OpenHostsEditorCommand : InvokableCommand +{ + public OpenHostsEditorCommand() + { + Name = "Open Hosts File Editor"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.HostsShow); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open Hosts File Editor: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ShowMouseJumpPreviewCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ShowMouseJumpPreviewCommand.cs new file mode 100644 index 0000000000..1d3a48fe62 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ShowMouseJumpPreviewCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Shows Mouse Jump preview via the shared event. +/// +internal sealed partial class ShowMouseJumpPreviewCommand : InvokableCommand +{ + public ShowMouseJumpPreviewCommand() + { + Name = "Show Mouse Jump Preview"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.MouseJumpShowPreview); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to show Mouse Jump preview: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleFindMyMouseCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleFindMyMouseCommand.cs new file mode 100644 index 0000000000..2dc1eb7a22 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleFindMyMouseCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Triggers Find My Mouse via the shared event. +/// +internal sealed partial class ToggleFindMyMouseCommand : InvokableCommand +{ + public ToggleFindMyMouseCommand() + { + Name = "Trigger Find My Mouse"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.FindMyMouseTrigger); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to trigger Find My Mouse: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseCrosshairsCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseCrosshairsCommand.cs new file mode 100644 index 0000000000..ccd5a6bf13 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseCrosshairsCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Toggles Mouse Pointer Crosshairs via the shared event. +/// +internal sealed partial class ToggleMouseCrosshairsCommand : InvokableCommand +{ + public ToggleMouseCrosshairsCommand() + { + Name = "Toggle Mouse Crosshairs"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.MouseCrosshairsTrigger); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to toggle Mouse Crosshairs: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseHighlighterCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseHighlighterCommand.cs new file mode 100644 index 0000000000..99a10f0fcd --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/MouseUtils/ToggleMouseHighlighterCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Toggles Mouse Highlighter via the shared event. +/// +internal sealed partial class ToggleMouseHighlighterCommand : InvokableCommand +{ + public ToggleMouseHighlighterCommand() + { + Name = "Toggle Mouse Highlighter"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.MouseHighlighterTrigger); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to toggle Mouse Highlighter: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/RegistryPreview/OpenRegistryPreviewCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/RegistryPreview/OpenRegistryPreviewCommand.cs new file mode 100644 index 0000000000..de62ab889f --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/RegistryPreview/OpenRegistryPreviewCommand.cs @@ -0,0 +1,35 @@ +// 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.Threading; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Helpers; + +namespace PowerToysExtension.Commands; + +/// +/// Launches Registry Preview via the shared event. +/// +internal sealed partial class OpenRegistryPreviewCommand : InvokableCommand +{ + public OpenRegistryPreviewCommand() + { + Name = "Open Registry Preview"; + } + + public override CommandResult Invoke() + { + try + { + using var evt = new EventWaitHandle(false, EventResetMode.AutoReset, PowerToysEventNames.RegistryPreviewTrigger); + evt.Set(); + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to open Registry Preview: {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ZoomIt/ZoomItActionCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ZoomIt/ZoomItActionCommand.cs new file mode 100644 index 0000000000..a2d9ae4f67 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Commands/ZoomIt/ZoomItActionCommand.cs @@ -0,0 +1,49 @@ +// 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.Pipes; +using System.Text; +using Microsoft.CommandPalette.Extensions.Toolkit; + +namespace PowerToysExtension.Commands; + +internal sealed partial class ZoomItActionCommand : InvokableCommand +{ + private readonly string _action; + private readonly string _title; + + private const string PipeName = "powertoys_zoomit_cmd"; + + public ZoomItActionCommand(string action, string title) + { + _action = action; + _title = title; + Name = title; + } + + public override CommandResult Invoke() + { + try + { + var payload = $"{{\"action\":\"{_action}\"}}"; + using var client = new NamedPipeClientStream( + ".", + PipeName, + PipeDirection.Out, + PipeOptions.Asynchronous); + + client.Connect(200); + var bytes = Encoding.UTF8.GetBytes(payload); + client.Write(bytes, 0, bytes.Length); + client.Flush(); + + return CommandResult.Dismiss(); + } + catch (Exception ex) + { + return CommandResult.ShowToast($"Failed to invoke ZoomIt ({_title}): {ex.Message}"); + } + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs index 9f426dc949..2ffdc54ec0 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/ModuleCommandCatalog.cs @@ -27,7 +27,25 @@ internal static class ModuleCommandCatalog new ScreenRulerModuleCommandProvider(), new ShortcutGuideModuleCommandProvider(), new TextExtractorModuleCommandProvider(), + new ZoomItModuleCommandProvider(), new ColorPickerModuleCommandProvider(), + new AlwaysOnTopModuleCommandProvider(), + new CropAndLockModuleCommandProvider(), + new FancyZonesModuleCommandProvider(), + new KeyboardManagerModuleCommandProvider(), + new MouseUtilsModuleCommandProvider(), + new MouseWithoutBordersModuleCommandProvider(), + new QuickAccentModuleCommandProvider(), + new FileExplorerAddonsModuleCommandProvider(), + new FileLocksmithModuleCommandProvider(), + new ImageResizerModuleCommandProvider(), + new NewPlusModuleCommandProvider(), + new PeekModuleCommandProvider(), + new PowerRenameModuleCommandProvider(), + new CommandNotFoundModuleCommandProvider(), + new EnvironmentVariablesModuleCommandProvider(), + new HostsModuleCommandProvider(), + new RegistryPreviewModuleCommandProvider(), ]; public static IListItem[] FilteredItems(string query) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs index 2e4fa69981..46c22e11fd 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Helpers/PowerToysEventNames.cs @@ -30,4 +30,8 @@ internal static class PowerToysEventNames internal const string WorkspacesHotkey = "Local\\PowerToys-Workspaces-HotkeyEvent-2625C3C8-BAC9-4DB3-BCD6-3B4391A26FD0"; internal const string CropAndLockThumbnail = "Local\\PowerToysCropAndLockThumbnailEvent-1637be50-da72-46b2-9220-b32b206b2434"; internal const string CropAndLockReparent = "Local\\PowerToysCropAndLockReparentEvent-6060860a-76a1-44e8-8d0e-6355785e9c36"; + internal const string FindMyMouseTrigger = "Local\\FindMyMouseTriggerEvent-5a9dc5f4-1c74-4f2f-a66f-1b9b6a2f9b23"; + internal const string MouseHighlighterTrigger = "Local\\MouseHighlighterTriggerEvent-1e3c9c3d-3fdf-4f9a-9a52-31c9b3c3a8f4"; + internal const string MouseCrosshairsTrigger = "Local\\MouseCrosshairsTriggerEvent-0d4c7f92-0a5c-4f5c-b64b-8a2a2f7e0b21"; + internal const string MouseJumpShowPreview = "Local\\MouseJumpEvent-aa0be051-3396-4976-b7ba-1a9cc7d236a5"; } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AdvancedPasteModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AdvancedPasteModuleCommandProvider.cs index 99bef8c7c0..05a48114fe 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AdvancedPasteModuleCommandProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AdvancedPasteModuleCommandProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using Common.UI; using Microsoft.CommandPalette.Extensions.Toolkit; using PowerToysExtension.Commands; using PowerToysExtension.Helpers; @@ -13,15 +14,21 @@ internal sealed class AdvancedPasteModuleCommandProvider : ModuleCommandProvider { public override IEnumerable BuildCommands() { - var icon = IconHelpers.FromRelativePath("Assets\\AdvancedPaste.png"); + var title = SettingsDeepLink.SettingsWindow.AdvancedPaste.ModuleDisplayName(); + var icon = SettingsDeepLink.SettingsWindow.AdvancedPaste.ModuleIcon(); - var item = new ListItem(new OpenAdvancedPasteCommand()) + yield return new ListItem(new OpenAdvancedPasteCommand()) { Title = "Open Advanced Paste", Subtitle = "Launch the Advanced Paste UI", Icon = icon, }; - return [item]; + yield return new ListItem(new OpenInSettingsCommand(SettingsDeepLink.SettingsWindow.AdvancedPaste, title)) + { + Title = title, + Subtitle = "Open Advanced Paste settings", + Icon = icon, + }; } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AlwaysOnTopModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AlwaysOnTopModuleCommandProvider.cs new file mode 100644 index 0000000000..cad8a282da --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/AlwaysOnTopModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class AlwaysOnTopModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.AlwaysOnTop.ModuleDisplayName(); + var icon = SettingsWindow.AlwaysOnTop.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.AlwaysOnTop, title)) + { + Title = title, + Subtitle = "Open Always On Top settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CommandNotFoundModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CommandNotFoundModuleCommandProvider.cs new file mode 100644 index 0000000000..2ec95172f9 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CommandNotFoundModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class CommandNotFoundModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.CmdNotFound.ModuleDisplayName(); + var icon = SettingsWindow.CmdNotFound.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.CmdNotFound, title)) + { + Title = title, + Subtitle = "Open Command Not Found settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CropAndLockModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CropAndLockModuleCommandProvider.cs new file mode 100644 index 0000000000..569894580d --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/CropAndLockModuleCommandProvider.cs @@ -0,0 +1,41 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class CropAndLockModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.CropAndLock.ModuleDisplayName(); + var icon = SettingsWindow.CropAndLock.ModuleIcon(); + + yield return new ListItem(new CropAndLockReparentCommand()) + { + Title = "Crop and Lock (Reparent)", + Subtitle = "Create a cropped reparented window", + Icon = icon, + }; + + yield return new ListItem(new CropAndLockThumbnailCommand()) + { + Title = "Crop and Lock (Thumbnail)", + Subtitle = "Create a cropped thumbnail window", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.CropAndLock, title)) + { + Title = title, + Subtitle = "Open Crop and Lock settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/EnvironmentVariablesModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/EnvironmentVariablesModuleCommandProvider.cs new file mode 100644 index 0000000000..ac74cec7db --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/EnvironmentVariablesModuleCommandProvider.cs @@ -0,0 +1,41 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class EnvironmentVariablesModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.EnvironmentVariables.ModuleDisplayName(); + var icon = SettingsWindow.EnvironmentVariables.ModuleIcon(); + + yield return new ListItem(new OpenEnvironmentVariablesCommand()) + { + Title = "Open Environment Variables", + Subtitle = "Launch Environment Variables editor", + Icon = icon, + }; + + yield return new ListItem(new OpenEnvironmentVariablesAdminCommand()) + { + Title = "Open Environment Variables (Admin)", + Subtitle = "Launch Environment Variables editor as admin", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.EnvironmentVariables, title)) + { + Title = title, + Subtitle = "Open Environment Variables settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FancyZonesModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FancyZonesModuleCommandProvider.cs new file mode 100644 index 0000000000..2fcd23860f --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FancyZonesModuleCommandProvider.cs @@ -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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class FancyZonesModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.FancyZones.ModuleDisplayName(); + var icon = SettingsWindow.FancyZones.ModuleIcon(); + + yield return new ListItem(new OpenFancyZonesEditorCommand()) + { + Title = "Open FancyZones Editor", + Subtitle = "Launch layout editor", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.FancyZones, title)) + { + Title = title, + Subtitle = "Open FancyZones settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileExplorerAddonsModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileExplorerAddonsModuleCommandProvider.cs new file mode 100644 index 0000000000..5fa5162cf8 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileExplorerAddonsModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class FileExplorerAddonsModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.FileExplorer.ModuleDisplayName(); + var icon = SettingsWindow.FileExplorer.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.FileExplorer, title)) + { + Title = title, + Subtitle = "Open File Explorer add-ons settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileLocksmithModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileLocksmithModuleCommandProvider.cs new file mode 100644 index 0000000000..19e5a135e5 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/FileLocksmithModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class FileLocksmithModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.FileLocksmith.ModuleDisplayName(); + var icon = SettingsWindow.FileLocksmith.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.FileLocksmith, title)) + { + Title = title, + Subtitle = "Open File Locksmith settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/HostsModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/HostsModuleCommandProvider.cs new file mode 100644 index 0000000000..d74437573c --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/HostsModuleCommandProvider.cs @@ -0,0 +1,41 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class HostsModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.Hosts.ModuleDisplayName(); + var icon = SettingsWindow.Hosts.ModuleIcon(); + + yield return new ListItem(new OpenHostsEditorCommand()) + { + Title = "Open Hosts File Editor", + Subtitle = "Launch Hosts File Editor", + Icon = icon, + }; + + yield return new ListItem(new OpenHostsEditorAdminCommand()) + { + Title = "Open Hosts File Editor (Admin)", + Subtitle = "Launch Hosts File Editor as admin", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.Hosts, title)) + { + Title = title, + Subtitle = "Open Hosts File Editor settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ImageResizerModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ImageResizerModuleCommandProvider.cs new file mode 100644 index 0000000000..6ec2f1b3a6 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ImageResizerModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class ImageResizerModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.ImageResizer.ModuleDisplayName(); + var icon = SettingsWindow.ImageResizer.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.ImageResizer, title)) + { + Title = title, + Subtitle = "Open Image Resizer settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/KeyboardManagerModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/KeyboardManagerModuleCommandProvider.cs new file mode 100644 index 0000000000..bb42f484a7 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/KeyboardManagerModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class KeyboardManagerModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.KBM.ModuleDisplayName(); + var icon = SettingsWindow.KBM.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.KBM, title)) + { + Title = title, + Subtitle = "Open Keyboard Manager settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseUtilsModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseUtilsModuleCommandProvider.cs new file mode 100644 index 0000000000..89fc109bc6 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseUtilsModuleCommandProvider.cs @@ -0,0 +1,55 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class MouseUtilsModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.MouseUtils.ModuleDisplayName(); + var icon = SettingsWindow.MouseUtils.ModuleIcon(); + + yield return new ListItem(new ToggleFindMyMouseCommand()) + { + Title = "Trigger Find My Mouse", + Subtitle = "Focus the mouse pointer", + Icon = icon, + }; + + yield return new ListItem(new ToggleMouseHighlighterCommand()) + { + Title = "Toggle Mouse Highlighter", + Subtitle = "Highlight mouse clicks", + Icon = icon, + }; + + yield return new ListItem(new ToggleMouseCrosshairsCommand()) + { + Title = "Toggle Mouse Crosshairs", + Subtitle = "Enable or disable pointer crosshairs", + Icon = icon, + }; + + yield return new ListItem(new ShowMouseJumpPreviewCommand()) + { + Title = "Show Mouse Jump Preview", + Subtitle = "Jump the pointer to a target", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.MouseUtils, title)) + { + Title = title, + Subtitle = "Open Mouse Utilities settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseWithoutBordersModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseWithoutBordersModuleCommandProvider.cs new file mode 100644 index 0000000000..49a3f3635a --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/MouseWithoutBordersModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class MouseWithoutBordersModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.MouseWithoutBorders.ModuleDisplayName(); + var icon = SettingsWindow.MouseWithoutBorders.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.MouseWithoutBorders, title)) + { + Title = title, + Subtitle = "Open Mouse Without Borders settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/NewPlusModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/NewPlusModuleCommandProvider.cs new file mode 100644 index 0000000000..f88d104b73 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/NewPlusModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class NewPlusModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.NewPlus.ModuleDisplayName(); + var icon = SettingsWindow.NewPlus.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.NewPlus, title)) + { + Title = title, + Subtitle = "Open New+ settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PeekModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PeekModuleCommandProvider.cs new file mode 100644 index 0000000000..a55a187206 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PeekModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class PeekModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.Peek.ModuleDisplayName(); + var icon = SettingsWindow.Peek.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.Peek, title)) + { + Title = title, + Subtitle = "Open Peek settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerRenameModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerRenameModuleCommandProvider.cs new file mode 100644 index 0000000000..434a1d53cf --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/PowerRenameModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class PowerRenameModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.PowerRename.ModuleDisplayName(); + var icon = SettingsWindow.PowerRename.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.PowerRename, title)) + { + Title = title, + Subtitle = "Open PowerRename settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/QuickAccentModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/QuickAccentModuleCommandProvider.cs new file mode 100644 index 0000000000..9122b3534c --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/QuickAccentModuleCommandProvider.cs @@ -0,0 +1,27 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class QuickAccentModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.PowerAccent.ModuleDisplayName(); + var icon = SettingsWindow.PowerAccent.ModuleIcon(); + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.PowerAccent, title)) + { + Title = title, + Subtitle = "Open Quick Accent settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/RegistryPreviewModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/RegistryPreviewModuleCommandProvider.cs new file mode 100644 index 0000000000..208c4b9ae1 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/RegistryPreviewModuleCommandProvider.cs @@ -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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class RegistryPreviewModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.RegistryPreview.ModuleDisplayName(); + var icon = SettingsWindow.RegistryPreview.ModuleIcon(); + + yield return new ListItem(new OpenRegistryPreviewCommand()) + { + Title = "Open Registry Preview", + Subtitle = "Launch Registry Preview", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.RegistryPreview, title)) + { + Title = title, + Subtitle = "Open Registry Preview settings", + Icon = icon, + }; + } +} diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ZoomItModuleCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ZoomItModuleCommandProvider.cs new file mode 100644 index 0000000000..f55552dcd3 --- /dev/null +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Modules/ZoomItModuleCommandProvider.cs @@ -0,0 +1,65 @@ +// 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.Collections.Generic; +using Microsoft.CommandPalette.Extensions.Toolkit; +using PowerToysExtension.Commands; +using PowerToysExtension.Helpers; +using static Common.UI.SettingsDeepLink; + +namespace PowerToysExtension.Modules; + +internal sealed class ZoomItModuleCommandProvider : ModuleCommandProvider +{ + public override IEnumerable BuildCommands() + { + var title = SettingsWindow.ZoomIt.ModuleDisplayName(); + var icon = SettingsWindow.ZoomIt.ModuleIcon(); + + // Action commands via ZoomIt IPC + yield return new ListItem(new ZoomItActionCommand("zoom", "ZoomIt: Zoom")) + { + Title = "ZoomIt: Zoom", + Subtitle = "Enter zoom mode", + Icon = icon, + }; + yield return new ListItem(new ZoomItActionCommand("draw", "ZoomIt: Draw")) + { + Title = "ZoomIt: Draw", + Subtitle = "Enter drawing mode", + Icon = icon, + }; + yield return new ListItem(new ZoomItActionCommand("break", "ZoomIt: Break")) + { + Title = "ZoomIt: Break", + Subtitle = "Enter break timer", + Icon = icon, + }; + yield return new ListItem(new ZoomItActionCommand("livezoom", "ZoomIt: Live Zoom")) + { + Title = "ZoomIt: Live Zoom", + Subtitle = "Toggle live zoom", + Icon = icon, + }; + yield return new ListItem(new ZoomItActionCommand("snip", "ZoomIt: Snip")) + { + Title = "ZoomIt: Snip", + Subtitle = "Enter snip mode", + Icon = icon, + }; + yield return new ListItem(new ZoomItActionCommand("record", "ZoomIt: Record")) + { + Title = "ZoomIt: Record", + Subtitle = "Start recording", + Icon = icon, + }; + + yield return new ListItem(new OpenInSettingsCommand(SettingsWindow.ZoomIt, title)) + { + Title = title, + Subtitle = "Open ZoomIt settings", + Icon = icon, + }; + } +}