Back to Powertoys

Windows Settings Plugin

doc/devdocs/modules/launcher/plugins/windowssettings.md

0.98.17.8 KB
Original Source

Windows Settings Plugin

The Windows settings Plugin allows users to search the Windows settings.

Special functions (differ from the regular functions)

  • Support modern Windows settings (Windows 10+)

  • Support legacy Windows settings (Windows 7, 8.1)

  • Support extra programs for setting (like ODBC)

  • Support search by the area of the setting (like Privacy)

  • Support search for alternative names of a setting

How to add a new Windows Setting or change one

All Windows settings are located in WindowsSettings.json in root folder of the project. The WindowsSettings.json use a JSON schema file that make it easier to edit it.

KeyOptionalValue typeString prefix
NameNoString
TypeNoStringApp
CommandNoString
AreasYesList with stringsArea
AltNamesYesList with strings
NoteYesStringNote
IntroducedInBuildYesInteger
DeprecatedInBuildYesInteger
ShowAsFirstResultYesBoolean

A minimum entry for the WindowsSettings.json looks like:

json
  {
    "Name": "mySetting",
    "Type": "AppSettingsApp",
    "Command": "ms-settings:mySetting"
  }

A full entry for the WindowsSettings.json looks like:

json
  {
    "Name": "mySetting",
    "Type": "AppSettingsApp",
    "Command": "ms-settings:mySetting",
    "Areas": [ "AreaMySettingArea" ],
    "AltNames": [ "NiceSetting" ],
    "Note": "NoteMySettingNote",
    "IntroducedInBuild" : 1903,
    "DeprecatedInBuild" : 2004,
    "ShowAsFirstResult" : true
  }

Remarks

  • The Command for modern Windows settings should start with ms-settings:
  • The Command for legacy Windows settings should start with control
  • The integer value for IntroducedInBuild and DeprecatedInBuild must be in range of 0 to 4294967295
  • The strings for Name, AltNames, Areas, Type and Note must not contain whitespace(s) or special characters (#, €, $, etc.)
  • The strings for Name, AltNames, Areas, Type and Note are used as ids for the resource file under Properties\Resources.resx
  • When you add new strings make sure you have added all translations for it.
  • If a result has mmc.exe as command and the note property is filled, the note is shown in the sub title too. (This is for special MMC results where we don't have a .msc file.)

Scores

There are three different score types with different start values.

Score typeStart value
First result score10500
High score10000
Medium score5000
Low score1000

Each score will decreased by one when a condition match.

PriorityConditionScore type
1.Settings name starts with the search valueHigh score
2.Settings name contain the search valueMedium score
3.Setting has no areaLow score
4.One area of the settings starts with the search valueLow score
5.Setting has no alternative nameLow score
6.One alternative name of the settings starts with the search valueMedium score
x.no condition matchLow score

Remarks

  • For each score condition we check if the property "ShowAsFirstResult" of the setting is true. If yes we use the firstResultScore instead of condition`s score.

Important for developers

General

  • The assembly name is cached into _assemblyName (to avoid to many calls of Assembly.GetExecutingAssembly())

Microsoft.PowerToys.Run.Plugin.WindowsSettings project

Important plugin values (meta-data)

NameValue
ActionKeyword$
ExecuteFileNameMicrosoft.PowerToys.Run.Plugin.WindowsSettings.dll
ID5043CECEE6A748679CBE02D27D83747A

Interfaces used by this plugin

The plugin use only these interfaces (all inside the Main.cs):

  • Wox.Plugin.IPlugin
  • Wox.Plugin.IContextMenu
  • Wox.Plugin.IPluginI18n

Program files

FileContent
Classes\WindowsSetting.csA class that represent one Windows setting
Classes\WindowsSettings.csA wrapper class that only contains a list with Windows settings (see 1)
Helper\ContextMenuHelper.csAll functions to build the context menu (for each result entry)
Helper\JsonSettingsListHelper.csAll functions to load the windows settings from a JSON file
Helper\ResultHelper.csAll functions to convert internal results into WOX results
Helper\TranslationHelper.csAll functions to translate the result in the surface language
Helper\UnsupportedSettingsHelper.csAll functions to filter not supported Windows settings out
Helper\WindowsSettingsPathHelper.csAll functions to build the area paths
Images\WindowsSettings.dark.pngSymbol for the results for the dark theme
Images\WindowsSettings.light.pngSymbol for the results for the light theme
Properties\Resources.Designer.resxFile that contain all translatable keys
Properties\Resources.resxFile that contain all translatable strings in the neutral language
Main.csMain class, the only place that implement the WOX interfaces
plugin.jsonAll meta-data for this plugin
  1. We need this extra wrapper class to make it possible that the JSON file can have and use a JSON schema file. Because the JSON file must have a object as root type, instead of a array.

Important project values (*.csproj)

NameValue
TargetFrameworknet6.0-windows (.NET 5) or net6.0-windows10.0.19041.0 (OS version specific)
Platformsx64
Output..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.WindowsSettings\
RootNamespaceMicrosoft.PowerToys.Run.Plugin.WindowsSettings
AssemblyNameMicrosoft.PowerToys.Run.Plugin.WindowsSettings

Project dependencies

Projects

  • Wox.Infrastructure
  • Wox.Plugin