mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Set window walker overview link (#1772)
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#include "resource.h"
|
||||||
|
#include "../../../common/version.h"
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 0,1,0,0
|
FILEVERSION 0,1,0,0
|
||||||
PRODUCTVERSION 0,1,0,0
|
PRODUCTVERSION 0,1,0,0
|
||||||
@@ -15,18 +18,25 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904b0"
|
BLOCK "040904b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Company Name"
|
VALUE "CompanyName", COMPANY_NAME
|
||||||
VALUE "FileDescription", "$projectname$ Module"
|
VALUE "FileDescription", "$projectname$ Module"
|
||||||
VALUE "FileVersion", "0.1.0.0"
|
VALUE "FileVersion", FILE_VERSION_STRING
|
||||||
VALUE "InternalName", "$projectname$"
|
VALUE "InternalName", "$projectname$"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2019 Company Name"
|
VALUE "LegalCopyright", COPYRIGHT_NOTE
|
||||||
VALUE "OriginalFilename", "$projectname$.dll"
|
VALUE "OriginalFilename", "$projectname$.dll"
|
||||||
VALUE "ProductName", "$projectname$"
|
VALUE "ProductName", "$projectname$"
|
||||||
VALUE "ProductVersion", "0.1.0.0"
|
VALUE "ProductVersion", PRODUCT_VERSION_STRING
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Translation", 0x409, 1200
|
VALUE "Translation", 0x409, 1200
|
||||||
END
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
STRINGTABLE
|
||||||
|
BEGIN
|
||||||
|
IDS_MODULE_NAME L"Window Walker"
|
||||||
|
IDS_GENERAL_DESCRIPTION L"A text-based Alt+Tab with search. Use Ctrl+Win to pop up."
|
||||||
|
IDS_OVERVIEW_LINK L"https://github.com/microsoft/PowerToys/blob/master/src/modules/windowwalker"
|
||||||
END
|
END
|
||||||
@@ -1,210 +1,212 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include <interface/powertoy_module_interface.h>
|
#include <interface/powertoy_module_interface.h>
|
||||||
#include <interface/lowlevel_keyboard_event_data.h>
|
#include <interface/lowlevel_keyboard_event_data.h>
|
||||||
#include <interface/win_hook_event_data.h>
|
#include <interface/win_hook_event_data.h>
|
||||||
#include <common/settings_objects.h>
|
#include <common/settings_objects.h>
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "resource.h"
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
|
||||||
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
|
||||||
{
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
switch (ul_reason_for_call)
|
{
|
||||||
{
|
switch (ul_reason_for_call)
|
||||||
case DLL_PROCESS_ATTACH:
|
{
|
||||||
Trace::RegisterProvider();
|
case DLL_PROCESS_ATTACH:
|
||||||
break;
|
Trace::RegisterProvider();
|
||||||
case DLL_THREAD_ATTACH:
|
break;
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_ATTACH:
|
||||||
break;
|
case DLL_THREAD_DETACH:
|
||||||
case DLL_PROCESS_DETACH:
|
break;
|
||||||
Trace::UnregisterProvider();
|
case DLL_PROCESS_DETACH:
|
||||||
break;
|
Trace::UnregisterProvider();
|
||||||
}
|
break;
|
||||||
return TRUE;
|
}
|
||||||
}
|
return TRUE;
|
||||||
|
}
|
||||||
// The PowerToy name that will be shown in the settings.
|
|
||||||
const static wchar_t* MODULE_NAME = L"Window Walker";
|
// These are the properties shown in the Settings page.
|
||||||
// Add a description that will we shown in the module settings page.
|
struct ModuleSettings
|
||||||
const static wchar_t* MODULE_DESC = L"A text-based Alt+Tab with search. Use Ctrl+Win to pop up";
|
{
|
||||||
|
|
||||||
// These are the properties shown in the Settings page.
|
} g_settings;
|
||||||
struct ModuleSettings
|
|
||||||
{
|
// Implement the PowerToy Module Interface and all the required methods.
|
||||||
|
class WindowWalker : public PowertoyModuleIface
|
||||||
} g_settings;
|
{
|
||||||
|
private:
|
||||||
// Implement the PowerToy Module Interface and all the required methods.
|
// The PowerToy name that will be show in the settings.
|
||||||
class WindowWalker : public PowertoyModuleIface
|
std::wstring m_appName;
|
||||||
{
|
|
||||||
private:
|
// The PowerToy state.
|
||||||
// The PowerToy state.
|
bool m_enabled = false;
|
||||||
bool m_enabled = false;
|
|
||||||
|
// Load initial settings from the persisted values.
|
||||||
// Load initial settings from the persisted values.
|
void init_settings();
|
||||||
void init_settings();
|
|
||||||
|
// Handle to the Window Walker app we launch
|
||||||
// Handle to the Window Walker app we launch
|
HANDLE m_hProcess;
|
||||||
HANDLE m_hProcess;
|
|
||||||
|
public:
|
||||||
public:
|
// Constructor
|
||||||
// Constructor
|
WindowWalker()
|
||||||
WindowWalker()
|
{
|
||||||
{
|
init_settings();
|
||||||
init_settings();
|
m_appName = GET_RESOURCE_STRING(IDS_MODULE_NAME);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destroy the powertoy and free memory
|
// Destroy the powertoy and free memory
|
||||||
virtual void destroy() override
|
virtual void destroy() override
|
||||||
{
|
{
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
TerminateProcess(m_hProcess, 1);
|
TerminateProcess(m_hProcess, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the display name of the powertoy, this will be cached by the runner
|
// Return the display name of the powertoy, this will be cached by the runner
|
||||||
virtual const wchar_t* get_name() override
|
virtual const wchar_t* get_name() override
|
||||||
{
|
{
|
||||||
return MODULE_NAME;
|
return m_appName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return array of the names of all events that this powertoy listens for, with
|
// Return array of the names of all events that this powertoy listens for, with
|
||||||
// nullptr as the last element of the array. Nullptr can also be retured for empty
|
// nullptr as the last element of the array. Nullptr can also be retured for empty
|
||||||
// list.
|
// list.
|
||||||
virtual const wchar_t** get_events() override
|
virtual const wchar_t** get_events() override
|
||||||
{
|
{
|
||||||
static const wchar_t* events[] = { nullptr };
|
static const wchar_t* events[] = { nullptr };
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return JSON with the configuration options.
|
// Return JSON with the configuration options.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||||
|
|
||||||
// Create a Settings object.
|
// Create a Settings object.
|
||||||
PowerToysSettings::Settings settings(hinstance, get_name());
|
PowerToysSettings::Settings settings(hinstance, get_name());
|
||||||
settings.set_description(MODULE_DESC);
|
settings.set_description(GET_RESOURCE_STRING(IDS_GENERAL_DESCRIPTION));
|
||||||
settings.set_icon_key(L"pt-window-walker");
|
settings.set_overview_link(GET_RESOURCE_STRING(IDS_OVERVIEW_LINK));
|
||||||
|
settings.set_icon_key(L"pt-window-walker");
|
||||||
return settings.serialize_to_buffer(buffer, buffer_size);
|
|
||||||
}
|
|
||||||
|
return settings.serialize_to_buffer(buffer, buffer_size);
|
||||||
// Signal from the Settings editor to call a custom action.
|
}
|
||||||
// This can be used to spawn more complex editors.
|
|
||||||
virtual void call_custom_action(const wchar_t* action) override
|
// Signal from the Settings editor to call a custom action.
|
||||||
{
|
// This can be used to spawn more complex editors.
|
||||||
static UINT custom_action_num_calls = 0;
|
virtual void call_custom_action(const wchar_t* action) override
|
||||||
try
|
{
|
||||||
{
|
static UINT custom_action_num_calls = 0;
|
||||||
// Parse the action values, including name.
|
try
|
||||||
PowerToysSettings::CustomActionObject action_object =
|
{
|
||||||
PowerToysSettings::CustomActionObject::from_json_string(action);
|
// Parse the action values, including name.
|
||||||
}
|
PowerToysSettings::CustomActionObject action_object =
|
||||||
catch (std::exception&)
|
PowerToysSettings::CustomActionObject::from_json_string(action);
|
||||||
{
|
}
|
||||||
// Improper JSON.
|
catch (std::exception&)
|
||||||
}
|
{
|
||||||
}
|
// Improper JSON.
|
||||||
|
}
|
||||||
// Called by the runner to pass the updated settings values as a serialized JSON.
|
}
|
||||||
virtual void set_config(const wchar_t* config) override
|
|
||||||
{
|
// Called by the runner to pass the updated settings values as a serialized JSON.
|
||||||
try
|
virtual void set_config(const wchar_t* config) override
|
||||||
{
|
{
|
||||||
// Parse the input JSON string.
|
try
|
||||||
PowerToysSettings::PowerToyValues values =
|
{
|
||||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
// Parse the input JSON string.
|
||||||
|
PowerToysSettings::PowerToyValues values =
|
||||||
values.save_to_settings_file();
|
PowerToysSettings::PowerToyValues::from_json_string(config);
|
||||||
}
|
|
||||||
catch (std::exception&)
|
values.save_to_settings_file();
|
||||||
{
|
}
|
||||||
// Improper JSON.
|
catch (std::exception&)
|
||||||
}
|
{
|
||||||
}
|
// Improper JSON.
|
||||||
|
}
|
||||||
// Enable the powertoy
|
}
|
||||||
virtual void enable()
|
|
||||||
{
|
// Enable the powertoy
|
||||||
SHELLEXECUTEINFO sei{ sizeof(sei) };
|
virtual void enable()
|
||||||
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
|
{
|
||||||
sei.lpFile = L"modules\\WindowWalker.exe";
|
SHELLEXECUTEINFO sei{ sizeof(sei) };
|
||||||
sei.nShow = SW_SHOWNORMAL;
|
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
|
||||||
ShellExecuteEx(&sei);
|
sei.lpFile = L"modules\\WindowWalker.exe";
|
||||||
|
sei.nShow = SW_SHOWNORMAL;
|
||||||
m_hProcess = sei.hProcess;
|
ShellExecuteEx(&sei);
|
||||||
|
|
||||||
m_enabled = true;
|
m_hProcess = sei.hProcess;
|
||||||
}
|
|
||||||
|
m_enabled = true;
|
||||||
// Disable the powertoy
|
}
|
||||||
virtual void disable()
|
|
||||||
{
|
// Disable the powertoy
|
||||||
if (m_enabled)
|
virtual void disable()
|
||||||
{
|
{
|
||||||
TerminateProcess(m_hProcess, 1);
|
if (m_enabled)
|
||||||
}
|
{
|
||||||
|
TerminateProcess(m_hProcess, 1);
|
||||||
m_enabled = false;
|
}
|
||||||
}
|
|
||||||
|
m_enabled = false;
|
||||||
// Returns if the powertoys is enabled
|
}
|
||||||
virtual bool is_enabled() override
|
|
||||||
{
|
// Returns if the powertoys is enabled
|
||||||
return m_enabled;
|
virtual bool is_enabled() override
|
||||||
}
|
{
|
||||||
|
return m_enabled;
|
||||||
// Handle incoming event, data is event-specific
|
}
|
||||||
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
|
|
||||||
{
|
// Handle incoming event, data is event-specific
|
||||||
if (wcscmp(name, ll_keyboard) == 0)
|
virtual intptr_t signal_event(const wchar_t* name, intptr_t data) override
|
||||||
{
|
{
|
||||||
auto& event = *(reinterpret_cast<LowlevelKeyboardEvent*>(data));
|
if (wcscmp(name, ll_keyboard) == 0)
|
||||||
// Return 1 if the keypress is to be suppressed (not forwarded to Windows),
|
{
|
||||||
// otherwise return 0.
|
auto& event = *(reinterpret_cast<LowlevelKeyboardEvent*>(data));
|
||||||
return 0;
|
// Return 1 if the keypress is to be suppressed (not forwarded to Windows),
|
||||||
}
|
// otherwise return 0.
|
||||||
else if (wcscmp(name, win_hook_event) == 0)
|
return 0;
|
||||||
{
|
}
|
||||||
auto& event = *(reinterpret_cast<WinHookEvent*>(data));
|
else if (wcscmp(name, win_hook_event) == 0)
|
||||||
// Return value is ignored
|
{
|
||||||
return 0;
|
auto& event = *(reinterpret_cast<WinHookEvent*>(data));
|
||||||
}
|
// Return value is ignored
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
// This methods are part of an experimental features not fully supported yet
|
}
|
||||||
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override
|
|
||||||
{
|
// This methods are part of an experimental features not fully supported yet
|
||||||
}
|
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) override
|
||||||
|
{
|
||||||
virtual void signal_system_menu_action(const wchar_t* name) override
|
}
|
||||||
{
|
|
||||||
}
|
virtual void signal_system_menu_action(const wchar_t* name) override
|
||||||
};
|
{
|
||||||
|
}
|
||||||
// Load the settings file.
|
};
|
||||||
void WindowWalker::init_settings()
|
|
||||||
{
|
// Load the settings file.
|
||||||
try
|
void WindowWalker::init_settings()
|
||||||
{
|
{
|
||||||
// Load and parse the settings file for this PowerToy.
|
try
|
||||||
PowerToysSettings::PowerToyValues settings =
|
{
|
||||||
PowerToysSettings::PowerToyValues::load_from_settings_file(WindowWalker::get_name());
|
// Load and parse the settings file for this PowerToy.
|
||||||
}
|
PowerToysSettings::PowerToyValues settings =
|
||||||
catch (std::exception&)
|
PowerToysSettings::PowerToyValues::load_from_settings_file(WindowWalker::get_name());
|
||||||
{
|
}
|
||||||
// Error while loading from the settings file. Let default values stay as they are.
|
catch (std::exception&)
|
||||||
}
|
{
|
||||||
}
|
// Error while loading from the settings file. Let default values stay as they are.
|
||||||
|
}
|
||||||
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
|
}
|
||||||
{
|
|
||||||
return new WindowWalker();
|
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
|
||||||
|
{
|
||||||
|
return new WindowWalker();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#define IDS_MODULE_NAME 100
|
||||||
|
#define IDS_GENERAL_DESCRIPTION 101
|
||||||
|
#define IDS_OVERVIEW_LINK 102
|
||||||
|
|||||||
Reference in New Issue
Block a user