mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
FancyZones and Shortcut Guide initial commit
Co-authored-by: Alexis Campailla <alexis@janeasystems.com> Co-authored-by: Bret Anderson <bretan@microsoft.com> Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Jeff Bogdan <jeffbog@microsoft.com> Co-authored-by: March Rogers <marchr@microsoft.com> Co-authored-by: Mike Harsh <mharsh@microsoft.com> Co-authored-by: Nachum Bundak <Nachum.Bundak@microsoft.com> Co-authored-by: Oliver Jones <ojones@microsoft.com> Co-authored-by: Patrick Little <plittle@microsoft.com>
This commit is contained in:
committed by
Bartosz Sosnowski
parent
10c5396099
commit
8431b80e48
BIN
tools/project_template/ModuleTemplate/ModuleTemplate.rc
Normal file
BIN
tools/project_template/ModuleTemplate/ModuleTemplate.rc
Normal file
Binary file not shown.
123
tools/project_template/ModuleTemplate/ModuleTemplate.vcxproj
Normal file
123
tools/project_template/ModuleTemplate/ModuleTemplate.vcxproj
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{44CC9375-3E6E-4D99-8913-7FB748807EBD}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>templatenamespace</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>ModuleTemplate</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\common\inc;..\..\common\Telemetry;..\;..\..\;..\..\..\deps\cpprestsdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\common\inc;..\..\common\Telemetry;..\;..\..\;..\..\..\deps\cpprestsdk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="trace.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="trace.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\common.vcxproj">
|
||||
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="$projectname$.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="trace.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="trace.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="$projectname$.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
44
tools/project_template/ModuleTemplate/README.md
Normal file
44
tools/project_template/ModuleTemplate/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# PowerToy ModuleTemplate
|
||||
|
||||
# Introduction
|
||||
This project is used to generate the Visual Studio PowerToys Module Template
|
||||
|
||||
# Instruction
|
||||
In Visual Studio from the menu Project->Export Template... generate the template.
|
||||
Set the name `PowerToys Module`, add a description `A project for creating a PowerToys module` and an icon.
|
||||
Open the resulting .zip file in `%USERNAME%\Documents\Visual Studio 2019\Templates\ProjectTemplates`
|
||||
and edit `MyTemplate.vstemplate` to make the necessary changes, the resulting template should look like this:
|
||||
|
||||
```xml
|
||||
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
|
||||
<TemplateData>
|
||||
<Name>PowerToys Module</Name>
|
||||
<Description>A project for creating a PowerToys module</Description>
|
||||
<ProjectType>VC</ProjectType>
|
||||
<ProjectSubType>
|
||||
</ProjectSubType>
|
||||
<LanguageTag>C++</LanguageTag>
|
||||
<PlatformTag>windows</PlatformTag>
|
||||
<ProjectTypeTag>extension</ProjectTypeTag>
|
||||
<SortOrder>1000</SortOrder>
|
||||
<CreateNewFolder>true</CreateNewFolder>
|
||||
<DefaultName>PowerToy</DefaultName>
|
||||
<ProvideDefaultName>true</ProvideDefaultName>
|
||||
<LocationField>Enabled</LocationField>
|
||||
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
|
||||
<Icon>__TemplateIcon.ico</Icon>
|
||||
</TemplateData>
|
||||
<TemplateContent>
|
||||
<Project TargetFileName="$projectname$.vcxproj" File="ModuleTemplate.vcxproj" ReplaceParameters="true">
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">ModuleTemplate.vcxproj.filters</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="dllmain.cpp">dllmain.cpp</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="pch.cpp">pch.cpp</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="trace.cpp">trace.cpp</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="pch.h">pch.h</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="resource.h">resource.h</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="false" TargetFileName="trace.h">trace.h</ProjectItem>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="$projectname$.rc">ModuleTemplate.rc</ProjectItem>
|
||||
</Project>
|
||||
</TemplateContent>
|
||||
</VSTemplate>
|
||||
```
|
||||
324
tools/project_template/ModuleTemplate/dllmain.cpp
Normal file
324
tools/project_template/ModuleTemplate/dllmain.cpp
Normal file
@@ -0,0 +1,324 @@
|
||||
#include "pch.h"
|
||||
#include <interface/powertoy_module_interface.h>
|
||||
#include <interface/lowlevel_keyboard_event_data.h>
|
||||
#include <interface/win_hook_event_data.h>
|
||||
#include <common/settings_objects.h>
|
||||
#include "trace.h"
|
||||
|
||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
Trace::RegisterProvider();
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
Trace::UnregisterProvider();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// The PowerToy name that will be shown in the settings.
|
||||
const static wchar_t* MODULE_NAME = L"$projectname$";
|
||||
// Add a description that will we shown in the module settings page.
|
||||
const static wchar_t* MODULE_DESC = L"<no description>";
|
||||
|
||||
// These are the properties shown in the Settings page.
|
||||
struct ModuleSettings {
|
||||
// Add the PowerToy module properties with default values.
|
||||
// Currently available types:
|
||||
// - int
|
||||
// - bool
|
||||
// - string
|
||||
|
||||
//bool bool_prop = true;
|
||||
//int int_prop = 10;
|
||||
//std::wstring string_prop = L"The quick brown fox jumps over the lazy dog";
|
||||
//std::wstring color_prop = L"#1212FF";
|
||||
|
||||
} g_settings;
|
||||
|
||||
// Implement the PowerToy Module Interface and all the required methods.
|
||||
class $safeprojectname$ : public PowertoyModuleIface {
|
||||
private:
|
||||
// The PowerToy state.
|
||||
bool m_enabled = false;
|
||||
|
||||
// Load initial settings from the persisted values.
|
||||
void init_settings();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
$safeprojectname$() {
|
||||
init_settings();
|
||||
};
|
||||
|
||||
// Destroy the powertoy and free memory
|
||||
virtual void destroy() override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
// Return the display name of the powertoy, this will be cached by the runner
|
||||
virtual const wchar_t* get_name() override {
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
// 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
|
||||
// list.
|
||||
virtual const wchar_t** get_events() override {
|
||||
static const wchar_t* events[] = { nullptr };
|
||||
// Available events:
|
||||
// - ll_keyboard
|
||||
// - win_hook_event
|
||||
//
|
||||
// static const wchar_t* events[] = { ll_keyboard,
|
||||
// win_hook_event,
|
||||
// nullptr };
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
// Return JSON with the configuration options.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override {
|
||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
|
||||
// Create a Settings object.
|
||||
PowerToysSettings::Settings settings(hinstance, get_name());
|
||||
settings.set_description(MODULE_DESC);
|
||||
|
||||
// Show an overview link in the Settings page
|
||||
//settings.set_overview_link(L"https://");
|
||||
|
||||
// Show a video link in the Settings page.
|
||||
//settings.set_video_link(L"https://");
|
||||
|
||||
// A bool property with a toggle editor.
|
||||
/*settings.add_bool_toogle(
|
||||
L"bool_toggle_1", // property name.
|
||||
L"This is what a BoolToggle property looks like", // description or resource id of the localized string.
|
||||
g_settings.bool_prop // property value.
|
||||
);*/
|
||||
|
||||
// An integer property with a spinner editor.
|
||||
/*settings.add_int_spinner(
|
||||
L"int_spinner_1", // property name
|
||||
L"This is what a IntSpinner property looks like", // description or resource id of the localized string.
|
||||
g_settings.int_prop, // property value.
|
||||
0, // min value.
|
||||
100, // max value.
|
||||
10 // incremental step.
|
||||
);*/
|
||||
|
||||
// A string property with a textbox editor.
|
||||
/*settings.add_string(
|
||||
L"string_text_1", // property name.
|
||||
L"This is what a String property looks like", // description or resource id of the localized string.
|
||||
g_settings.string_prop // property value.
|
||||
);*/
|
||||
|
||||
// A string property with a color picker editor.
|
||||
/*settings.add_color_picker(
|
||||
L"color_picker_1", // property name.
|
||||
L"This is what a ColorPicker property looks like", // description or resource id of the localized string.
|
||||
g_settings.color_prop // property value.
|
||||
);*/
|
||||
|
||||
// A custom action property. When using this settings type, the "PowertoyModuleIface::call_custom_action()"
|
||||
// method should be overriden as well.
|
||||
/*settings.add_custom_action(
|
||||
L"custom_action_id", // action name.
|
||||
L"This is what a CustomAction property looks like", // label above the field.
|
||||
L"Call a custom action", // button text.
|
||||
L"Press the button to call a custom action." // display values / extended info.
|
||||
);*/
|
||||
|
||||
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 {
|
||||
static UINT custom_action_num_calls = 0;
|
||||
try {
|
||||
// Parse the action values, including name.
|
||||
PowerToysSettings::CustomActionObject action_object =
|
||||
PowerToysSettings::CustomActionObject::from_json_string(action);
|
||||
|
||||
/*
|
||||
if (action_object.get_name() == L"custom_action_id") {
|
||||
// Execute your custom action
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
// 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 {
|
||||
try {
|
||||
// Parse the input JSON string.
|
||||
PowerToysSettings::PowerToyValues values =
|
||||
PowerToysSettings::PowerToyValues::from_json_string(config);
|
||||
|
||||
// Update a bool property.
|
||||
/*
|
||||
if (values.is_bool_value(L"bool_toggle_1")) {
|
||||
g_settings.bool_prop = values.get_bool_value(L"bool_toggle_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Update an int property.
|
||||
/*
|
||||
if (values.is_int_value(L"int_spinner_1")) {
|
||||
g_settings.int_prop = values.get_int_value(L"int_spinner_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Update a string property.
|
||||
/*
|
||||
if (values.is_string_value(L"string_text_1")) {
|
||||
g_settings.string_prop = values.get_string_value(L"string_text_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Update a color property.
|
||||
/*
|
||||
if (values.is_string_value(L"color_picker_1")) {
|
||||
g_settings.color_prop = values.get_string_value(L"color_picker_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// If you don't need to do any custom processing of the settings, proceed
|
||||
// to persists the values calling:
|
||||
values.save_to_settings_file();
|
||||
// Otherwise call a custom function to process the settings before saving them to disk:
|
||||
// save_settings();
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
// Improper JSON.
|
||||
}
|
||||
}
|
||||
|
||||
// Enable the powertoy
|
||||
virtual void enable() {
|
||||
m_enabled = true;
|
||||
}
|
||||
|
||||
// Disable the powertoy
|
||||
virtual void disable() {
|
||||
m_enabled = false;
|
||||
}
|
||||
|
||||
// Returns if the powertoys is 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 {
|
||||
if (wcscmp(name, ll_keyboard) == 0) {
|
||||
auto& event = *(reinterpret_cast<LowlevelKeyboardEvent*>(data));
|
||||
// Return 1 if the keypress is to be suppressed (not forwarded to Windows),
|
||||
// otherwise return 0.
|
||||
return 0;
|
||||
}
|
||||
else if (wcscmp(name, win_hook_event) == 0) {
|
||||
auto& event = *(reinterpret_cast<WinHookEvent*>(data));
|
||||
// Return value is ignored
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Load the settings file.
|
||||
void $safeprojectname$::init_settings() {
|
||||
try {
|
||||
// Load and parse the settings file for this PowerToy.
|
||||
PowerToysSettings::PowerToyValues settings =
|
||||
PowerToysSettings::PowerToyValues::load_from_settings_file(get_name());
|
||||
|
||||
// Load a bool property.
|
||||
/*
|
||||
if (settings.is_bool_value(L"bool_toggle_1")) {
|
||||
g_settings.bool_prop = settings.get_bool_value(L"bool_toggle_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Load an int property.
|
||||
/*
|
||||
if (settings.is_int_value(L"int_spinner_1")) {
|
||||
g_settings.int_prop = settings.get_int_value(L"int_spinner_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Load a string property.
|
||||
/*
|
||||
if (settings.is_string_value(L"string_text_1")) {
|
||||
g_settings.string_prop = settings.get_string_value(L"string_text_1");
|
||||
}
|
||||
*/
|
||||
|
||||
// Load a color property.
|
||||
/*
|
||||
if (settings.is_string_value(L"color_picker_1")) {
|
||||
g_settings.color_prop = settings.get_string_value(L"color_picker_1");
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
// Error while loading from the settings file. Let default values stay as they are.
|
||||
}
|
||||
}
|
||||
|
||||
// This method of saving the module settings is only required if you need to do any
|
||||
// custom processing of the settings before saving them to disk.
|
||||
/*
|
||||
void $projectname$::save_settings() {
|
||||
try {
|
||||
// Create a PowerToyValues object for this PowerToy
|
||||
PowerToysSettings::PowerToyValues values(get_name());
|
||||
|
||||
// Save a bool property.
|
||||
//values.add_property(
|
||||
// L"bool_toggle_1", // property name
|
||||
// g_settings.bool_prop // property value
|
||||
//);
|
||||
|
||||
// Save an int property.
|
||||
//values.add_property(
|
||||
// L"int_spinner_1", // property name
|
||||
// g_settings.int_prop // property value
|
||||
//);
|
||||
|
||||
// Save a string property.
|
||||
//values.add_property(
|
||||
// L"string_text_1", // property name
|
||||
// g_settings.string_prop // property value
|
||||
);
|
||||
|
||||
// Save a color property.
|
||||
//values.add_property(
|
||||
// L"color_picker_1", // property name
|
||||
// g_settings.color_prop // property value
|
||||
//);
|
||||
|
||||
// Save the PowerToyValues JSON to the power toy settings file.
|
||||
values.save_to_settings_file();
|
||||
}
|
||||
catch (std::exception ex) {
|
||||
// Couldn't save the settings.
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() {
|
||||
return new $safeprojectname$();
|
||||
}
|
||||
2
tools/project_template/ModuleTemplate/pch.cpp
Normal file
2
tools/project_template/ModuleTemplate/pch.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "pch.h"
|
||||
#pragma comment(lib, "windowsapp")
|
||||
5
tools/project_template/ModuleTemplate/pch.h
Normal file
5
tools/project_template/ModuleTemplate/pch.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <common/common.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
0
tools/project_template/ModuleTemplate/resource.h
Normal file
0
tools/project_template/ModuleTemplate/resource.h
Normal file
26
tools/project_template/ModuleTemplate/trace.cpp
Normal file
26
tools/project_template/ModuleTemplate/trace.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "pch.h"
|
||||
#include "trace.h"
|
||||
|
||||
TRACELOGGING_DEFINE_PROVIDER(
|
||||
g_hProvider,
|
||||
"Microsoft.PowerToys",
|
||||
// {38e8889b-9731-53f5-e901-e8a7c1753074}
|
||||
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
|
||||
TraceLoggingOptionProjectTelemetry());
|
||||
|
||||
void Trace::RegisterProvider() {
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::UnregisterProvider() {
|
||||
TraceLoggingUnregister(g_hProvider);
|
||||
}
|
||||
|
||||
void Trace::MyEvent() {
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"PowerToyName::Event::MyEvent",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
8
tools/project_template/ModuleTemplate/trace.h
Normal file
8
tools/project_template/ModuleTemplate/trace.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
class Trace {
|
||||
public:
|
||||
static void RegisterProvider();
|
||||
static void UnregisterProvider();
|
||||
static void MyEvent();
|
||||
};
|
||||
Reference in New Issue
Block a user