// 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 #include #include #include /// /// Wrapper class for loading and managing a PowerToy module DLL /// class ModuleLoader { public: ModuleLoader(); ~ModuleLoader(); // Prevent copying ModuleLoader(const ModuleLoader&) = delete; ModuleLoader& operator=(const ModuleLoader&) = delete; /// /// Load a PowerToy module DLL /// /// Path to the module DLL /// True if successful, false otherwise bool Load(const std::wstring& dllPath); /// /// Enable the loaded module /// void Enable(); /// /// Disable the loaded module /// void Disable(); /// /// Check if the module is enabled /// /// True if enabled, false otherwise bool IsEnabled() const; /// /// Set configuration for the module /// /// JSON configuration string void SetConfig(const std::wstring& configJson); /// /// Get the module's localized name /// /// Module name std::wstring GetModuleName() const; /// /// Get the module's non-localized key /// /// Module key std::wstring GetModuleKey() const; /// /// Get the module's hotkeys /// /// Buffer to store hotkeys /// Size of the buffer /// Number of hotkeys returned size_t GetHotkeys(PowertoyModuleIface::Hotkey* buffer, size_t bufferSize); /// /// Trigger a hotkey callback on the module /// /// ID of the hotkey to trigger /// True if the key press should be swallowed bool OnHotkey(size_t hotkeyId); /// /// Check if the module is loaded /// /// True if loaded, false otherwise bool IsLoaded() const { return m_module != nullptr; } /// /// Get the module's activation hotkey (newer HotkeyEx API) /// /// Optional HotkeyEx struct std::optional GetHotkeyEx(); /// /// Trigger the newer-style hotkey callback on the module /// void OnHotkeyEx(); private: HMODULE m_hModule; PowertoyModuleIface* m_module; std::wstring m_dllPath; };