Add copying keyboard manifests and other improvements

This commit is contained in:
Aaron Junker 2025-06-11 15:26:34 +02:00 committed by Gordon Lam (SH)
parent 44d12c6e63
commit 9ecf82d2ea
15 changed files with 1366 additions and 33 deletions

View File

@ -107,7 +107,7 @@
<PackageVersion Include="WinUIEx" Version="2.2.0" />
<PackageVersion Include="WPF-UI" Version="3.0.5" />
<PackageVersion Include="WyHash" Version="1.0.5" />
<PackageVersion Include="YamlDotNet" Version="16.1.3" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(IsExperimentationLive)'!=''">
<!-- Additional dependencies used by experimentation -->

View File

@ -0,0 +1,75 @@
// 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 System.IO;
using ShortcutGuide.Models;
using YamlDotNet.Serialization;
// This should all be outsourced to WinGet in the future
namespace ShortcutGuide.IndexYmlGenerator
{
public class IndexYmlGenerator
{
public static void Main()
{
CreateIndexYmlFile();
}
// Todo: Exception handling
public static void CreateIndexYmlFile()
{
string path = ManifestInterpreter.GetPathOfIntepretations();
if (File.Exists(Path.Combine(path, "index.yml")))
{
File.Delete(Path.Combine(path, "index.yml"));
}
IndexFile indexFile = new() { };
Dictionary<(string WindowFilter, bool BackgroundProcess), List<string>> processes = [];
foreach (string file in Directory.EnumerateFiles(path, "*.yml"))
{
string content = File.ReadAllText(file);
Deserializer deserializer = new();
ShortcutFile shortcutFile = deserializer.Deserialize<ShortcutFile>(content);
if (processes.TryGetValue((shortcutFile.WindowFilter, shortcutFile.BackgroundProcess), out List<string>? apps))
{
if (apps.Contains(shortcutFile.PackageName))
{
continue;
}
apps.Add(shortcutFile.PackageName);
continue;
}
processes[(shortcutFile.WindowFilter, shortcutFile.BackgroundProcess)] = [shortcutFile.PackageName];
}
indexFile.Index = [];
foreach (var item in processes)
{
indexFile.Index =
[
.. indexFile.Index,
new IndexFile.IndexItem
{
WindowFilter = item.Key.WindowFilter,
BackgroundProcess = item.Key.BackgroundProcess,
Apps = [.. item.Value],
},
];
}
// Todo: Take the default shell name from the settings or environment variable, default to "+WindowsNT.Shell"
indexFile.DefaultShellName = "+WindowsNT.Shell";
Serializer serializer = new();
string yamlContent = serializer.Serialize(indexFile);
File.WriteAllText(Path.Combine(path, "index.yml"), yamlContent);
}
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Look at Directory.Build.props in root for common stuff as well -->
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
<Import Project="..\..\..\..\Common.SelfContained.props" />
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>ShortcutGuide.IndexYmlGenerator</RootNamespace>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<OutputPath>..\..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps</OutputPath>
<AssemblyName>PowerToys.ShortcutGuide.IndexYmlGenerator</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ShortcutGuide.Ui\ShortcutGuide.Ui.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,247 @@
PackageName: +WindowsNT.Notepad
Name: Notepad
WindowFilter: "Notepad.exe"
BackgroundProcess: false
Shortcuts:
- SectionName: File
Properties:
- Name: New tab
Recommended: true
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- N
- Name: New window
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- N
- Name: Open
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- O
- Name: Save
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- S
- Name: Save As
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- S
- Name: Save all
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: true
Keys:
- S
- Name: Print
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- P
- Name: Close tab
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- W
- Name: Close window
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- W
- SectionName: Edit
Properties:
- Name: Undo
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- Z
- Name: Redo
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: true
Keys:
- Z
- Name: Cut
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- X
- Name: Copy
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- C
- Name: Paste
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- V
- Name: Search with Bing
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- E
- Name: Find
Recommended: true
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- F
- Name: Find next
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- F3
- Name: Find previous
Shortcut:
- Win: false
Ctrl: false
Shift: true
Alt: false
Keys:
- F3
- Name: Replace
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- H
- Name: Go to
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- G
- Name: Select all
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- A
- Name: Time/Date
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- F5
- SectionName: View
Properties:
- Name: Zoom in
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- Plus
- Name: Zoom out
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- Minus
- Name: Reset zoom
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- 0
- SectionName: Formatting
Properties:
- Name: Bold
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- B
- Name: Italic
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- I
- Name: Insert link
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- K
- Name: Clear formatting
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- Space

View File

@ -0,0 +1,778 @@
PackageName: +WindowsNT.Shell
WindowFilter: "*"
BackgroundProcess: true
Shortcuts:
- SectionName: Desktop Shortcuts
Properties:
- Name: Close active window
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- F4
- Name: Open shutdown box
Description: When no windows are open
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- F4
- Name: Cycle through open Windows
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- Esc
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- Esc
- Name: Reveal typed password
Description: On sign-in screen
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- F8
- Name: Go back
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- "<Left>"
- Name: Go forward
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- "<Right>"
- Name: Move up one screen
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- "<Page Up>"
- Name: Move down one screen
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- "<Page Down>"
- Name: Window context menu
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- Space
- Name: Switch between open apps
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- Tab
Description: While pressing Tab multiple times
- Name: Run command
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: true
Keys:
- "<Underlined letter>"
Description: for the underlined letter in the app
- Name: View open apps
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: true
Keys:
- Tab
- Name: Change start menu size
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- "<Arrow>"
- Name: Move cursor
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- "<ArrowLR>"
Description: To the beginning or end of a word
- Name: Switch keyboard layout
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- ""
- Name: Select block of text
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- "<Arrow>"
- Name: Open Task Manager
Shortcut:
- Win: false
Ctrl: true
Shift: true
Alt: false
Keys:
- Esc
- Name: Enable/Disable Chinese IME
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- Space
- Name: Open context menu
Shortcut:
- Win: false
Ctrl: false
Shift: true
Alt: false
Keys:
- F10
Description: For the selected item
- SectionName: Virtual desktop
Properties:
- Name: Open task view
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- Tab
- Name: Add a virtual desktop
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- D
- Name: Close current desktop
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- F4
Recommended: true
- Name: Switch desktop
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "<ArrowLR>"
- SectionName: "Windows key"
Properties:
- Name: Open start menu
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- ""
Recommended: true
- Name: Open Action Center
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "A"
- Name: Open Date and Time
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: true
Keys:
- "D"
- Name: Focus on the notification area
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "B"
- Name: Open narrator
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "Enter"
- Name: Open domain search
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "F"
- Name: Open Quick Assist
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "Q"
- Name: Wake up device
Shortcut:
- Win: true
Ctrl: true
Shift: true
Alt: false
Keys:
- "B"
Description: When black or a blank screen.
- Name: Change input option
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Space"
Description: To next option
- Name: Change input option
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "Space"
Description: To previous option
- Name: Display/Hide desktop
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "D"
- Name: Minimize the active window
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Down"
- Name: Open file Explorer
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "E"
- Name: Close Magnifier
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Esc"
- Name: Open Feedback Hub
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "F"
- Name: Start IME reconversion
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "/"
- Name: Open Gamebar
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "G"
- Name: Open voice dictation
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "H"
- Name: Minimize or restore all other windows
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Home>"
- Name: Open Settings
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "I"
- Name: Set focus to a Windows tip
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "J"
- Name: Open Cast
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "K"
- Name: Lock the device
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "L"
- Name: Snap the window
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<ArrowLR>"
- Name: Minimize all windows
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "M"
- Name: Zoom out Magnifier
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "-"
- Name: Zoom in Magnifier
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "="
- Name: Open notification center
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "N"
- Name: Lock the device orientation
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "O"
- Name: Open project Settings
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "P"
- Name: Open Settings about Page
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Pause>"
- Name: Open the emoji panel
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "."
- Name: Open the emoji panel
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- ";"
- Name: Capture a screenshot
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<PrtSc>"
Description: Save to the pictures folder
- Name: Open search
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Q"
- Name: Open search
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "S"
- Name: Open Run dialog
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "R"
- Name: Restore window
Description: If a window is snapped or maximized
Shortcut:
- Win: true
Ctrl: false
Shift: true
Alt: false
Keys:
- "<Down>"
- Name: Make UWP app full screen
Shortcut:
- Win: true
Ctrl: false
Shift: true
Alt: false
Keys:
- "<Up>"
- Name: Move window to monitor
Shortcut:
- Win: true
Ctrl: false
Shift: true
Alt: false
Keys:
- "<Arrow>"
- Name: Open Snipping Tool
Shortcut:
- Win: true
Ctrl: false
Shift: true
Alt: false
Keys:
- "S"
- Name: Stretch window
Description: To the top and bottom of the screen
Shortcut:
- Win: true
Ctrl: false
Shift: true
Alt: false
Keys:
- "<Up>"
- Name: Open task view
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Tab"
- Name: Open Accessibility Settings
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "U"
- Name: Maximize the active window
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Up>"
- Name: Open the clipboard history
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "V"
- Name: Open widgets
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "W"
- Name: Open Quick Link menu
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "X"
- Name: Open snap layouts
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "Z"
- SectionName: Clipboard
Properties:
- Name: Copy
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- "C"
- Name: Cut
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- "X"
- Name: Paste
Shortcut:
- Win: false
Ctrl: true
Shift: false
Alt: false
Keys:
- "V"
- Name: Paste
Shortcut:
- Win: false
Ctrl: false
Shift: true
Alt: false
Keys:
- "<Insert>"
Description: Paste as plain text
- SectionName: <TASKBAR1-9>Taskbar Shortcuts
Properties:
- Name: Open app in Taskbar
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: false
Keys:
- "<TASKBAR1-9>"
- Name: Open jump list
Shortcut:
- Win: true
Ctrl: false
Shift: false
Alt: true
Keys:
- "<TASKBAR1-9>"
- Name: Switch to last active window
Shortcut:
- Win: true
Ctrl: true
Shift: false
Alt: false
Keys:
- "<TASKBAR1-9>"
- Name: Open as administrator
Shortcut:
- Win: true
Ctrl: true
Shift: true
Alt: false
Keys:
- "<TASKBAR1-9>"
- SectionName: Copilot key
Properties:
- Name: Open Copilot
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- '<Copilot>'
Description: When copilot is available
- Name: Open Windows search
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- '<Copilot>'
Description: When copilot is not available
- SectionName: Office key
Properties:
- Name: Open Word
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "W"
- Name: Open Excel
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "X"
- Name: Open PowerPoint
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "P"
- Name: Open Outlook
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "O"
- Name: Open Microsoft Teams
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "T"
- Name: Open OneNote
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "N"
- Name: Open OneDrive
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "D"
- Name: Open Yammer
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "Y"
- Name: Open LinkedIn
Shortcut:
- Win: false
Ctrl: false
Shift: false
Alt: false
Keys:
- "<Office>"
- "L"

View File

@ -0,0 +1,3 @@
PackageName: +WindowsNT.WindowsExplorer
WindowFilter: "explorer.exe"
Shortcuts:

View File

@ -0,0 +1,165 @@
PackageName: Microsoft.PowerToys
Name: PowerToys
BackgroundProcess: True
WindowFilter: "powertoys.exe"
Shortcuts:
- SectionName: General
Properties:
# <Populate start>
- Name: Advanced Paste
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 86
Description: Open Advanced Paste window
- Name: Advanced Paste
Shortcut:
- Win: True
Ctrl: True
Alt: True
Shift: False
Keys:
- 86
Description: Paste as plain text directly
- Name: Advanced Paste
Shortcut:
- Win: False
Ctrl: False
Alt: False
Shift: False
Keys:
- 0
Description: Paste as markdown directly
- Name: Advanced Paste
Shortcut:
- Win: False
Ctrl: False
Alt: False
Shift: False
Keys:
- 0
Description: Paste as JSON directly
- Name: Always On Top
Shortcut:
- Win: True
Ctrl: True
Alt: False
Shift: False
Keys:
- 84
Description: Pin a window
- Name: Color Picker
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 67
Description: Pick a color
- Name: Crop And Lock
Shortcut:
- Win: True
Ctrl: True
Alt: False
Shift: True
Keys:
- 84
Description: Thumbnail
- Name: Crop And Lock
Shortcut:
- Win: True
Ctrl: True
Alt: False
Shift: True
Keys:
- 82
Description: Reparent
- Name: FancyZones
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 192
Description: Open editor
- Name: Mouse Highlight
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 72
Description: Highlight clicks
- Name: Mouse Jump
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 68
Description: Quickly move the mouse pointer
- Name: Mouse Pointer Crosshairs
Shortcut:
- Win: True
Ctrl: False
Alt: True
Shift: False
Keys:
- 80
Description: Show crosshairs
- Name: Peek
Shortcut:
- Win: False
Ctrl: True
Alt: False
Shift: False
Keys:
- 32
- Name: PowerToys Run
Shortcut:
- Win: False
Ctrl: False
Alt: True
Shift: False
Keys:
- 32
- Name: Screen Ruler
Shortcut:
- Win: True
Ctrl: True
Alt: False
Shift: True
Keys:
- 77
- Name: Shortcut Guide
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 191
- Name: Text Extractor
Shortcut:
- Win: True
Ctrl: False
Alt: False
Shift: True
Keys:
- 84
- Name: Workspaces
Shortcut:
- Win: True
Ctrl: True
Alt: False
Shift: False
Keys:
- 192
# <Populate end>

View File

@ -17,17 +17,32 @@ namespace ShortcutGuide
{
public class ManifestInterpreter
{
public static ShortcutList GetShortcutsOfApplication(string applicationName)
// Todo: Get language from settings or environment variable, default to "en-US"
public static string Language => "en-US";
public static ShortcutFile GetShortcutsOfApplication(string applicationName)
{
string path = GetPathOfIntepretations();
string content = File.ReadAllText(Path.Combine(path, applicationName + ".yml"));
return YamlToShortcutList(content);
IEnumerable<string> files = Directory.EnumerateFiles(path, applicationName + ".*.yml") ??
throw new FileNotFoundException($"The file for the application '{applicationName}' was not found in '{path}'.");
if (files.Any(f => f.EndsWith($".{Language}.yml", StringComparison.InvariantCulture)))
{
return YamlToShortcutList(File.ReadAllText(Path.Combine(path, applicationName + $".{Language}.yml")));
}
public static ShortcutList YamlToShortcutList(string content)
if (files.Any(f => f.EndsWith(".en-US.yml", StringComparison.InvariantCulture)))
{
return YamlToShortcutList(File.ReadAllText(files.First(f => f.EndsWith(".en-US.yml", StringComparison.InvariantCulture))));
}
throw new FileNotFoundException($"The file for the application '{applicationName}' was not found in '{path}' with the language '{Language}' or 'en-US'.");
}
public static ShortcutFile YamlToShortcutList(string content)
{
Deserializer deserializer = new();
return deserializer.Deserialize<ShortcutList>(content);
return deserializer.Deserialize<ShortcutFile>(content);
}
public static string GetPathOfIntepretations()
@ -59,6 +74,25 @@ namespace ShortcutGuide
var processes = Process.GetProcesses();
if (NativeMethods.GetWindowThreadProcessId(handle, out uint processId) > 0)
{
string? name = Process.GetProcessById((int)processId).MainModule?.ModuleName;
if (name is not null)
{
try
{
foreach (var item in GetIndexYamlFile().Index.First((s) => !s.BackgroundProcess && IsMatch(name, s.WindowFilter)).Apps)
{
applicationIds.Add(item);
}
}
catch (InvalidOperationException)
{
}
}
}
foreach (var item in GetIndexYamlFile().Index.Where((s) => s.BackgroundProcess))
{
try
@ -86,29 +120,10 @@ namespace ShortcutGuide
}
}
if (NativeMethods.GetWindowThreadProcessId(handle, out uint processId) > 0)
{
string? name = Process.GetProcessById((int)processId).MainModule?.ModuleName;
if (name is not null)
{
try
{
foreach (var item in GetIndexYamlFile().Index.First((s) => !s.BackgroundProcess && IsMatch(name, s.WindowFilter)).Apps)
{
applicationIds.Add(item);
}
}
catch (InvalidOperationException)
{
}
}
}
return [.. applicationIds];
}
public static ShortcutList GetShortcutsOfDefaultShell()
public static ShortcutFile GetShortcutsOfDefaultShell()
{
return GetShortcutsOfApplication(GetIndexYamlFile().DefaultShellName);
}

View File

@ -4,7 +4,7 @@
namespace ShortcutGuide.Models
{
public struct ShortcutList
public struct ShortcutFile
{
public string PackageName { get; set; }

View File

@ -14,7 +14,7 @@ namespace ShortcutGuide
{
public static void Populate()
{
string path = Path.Combine(ManifestInterpreter.GetPathOfIntepretations(), "Microsoft.PowerToys.yml");
string path = Path.Combine(ManifestInterpreter.GetPathOfIntepretations(), $"Microsoft.PowerToys.{ManifestInterpreter.Language}.yml");
string content = File.ReadAllText(path);

View File

@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using ManagedCommon;
using Microsoft.UI.Dispatching;
@ -12,9 +14,29 @@ namespace ShortcutGuide
{
public sealed class Program
{
private static readonly string[] InbuiltManifestFiles = [
"+WindowsNT.Shell.en-US.yml",
"+WindowsNT.WindowsExplorer.en-US.yml",
"+WindowsNT.Notepad.en-US.yml",
"Microsoft.PowerToys.en-US.yml",
];
[STAThread]
public static void Main()
{
if (!Directory.Exists(ManifestInterpreter.GetPathOfIntepretations()))
{
Directory.CreateDirectory(ManifestInterpreter.GetPathOfIntepretations());
}
// Todo: Only copy files after an update.
// Todo: Handle error
foreach (var file in InbuiltManifestFiles)
{
File.Copy(Path.GetDirectoryName(Environment.ProcessPath) + "\\Assets\\ShortcutGuide\\" + file, ManifestInterpreter.GetPathOfIntepretations() + "\\" + file, true);
}
Process.Start(Path.GetDirectoryName(Environment.ProcessPath) + "\\PowerToys.ShortcutGuide.IndexYmlGenerator.exe");
PowerToysShortcutsPopulator.Populate();
Logger.InitializeLogger("\\ShortcutGuide\\Logs");

View File

@ -24,6 +24,9 @@
<ItemGroup>
<Content Remove="Assets\CopilotKey.png" />
<Content Remove="Assets\ShortcutGuide\+WindowsNT.Shell.en-US.yml" />
<Content Remove="Assets\ShortcutGuide\+WindowsNT.WindowsExplorer.en-US.yml" />
<Content Remove="Assets\ShortcutGuide\Microsoft.PowerToys.en-US.yml" />
<Content Remove="Assets\ShortcutGuide\OfficeKey.png" />
</ItemGroup>

View File

@ -20,8 +20,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<SelectorBar Grid.Column="0" Grid.Row="0" x:Name="WindowSelector" SelectionChanged="WindowSelectionChanged">
</SelectorBar>
<SelectorBar Grid.Column="0" Grid.Row="0" x:Name="WindowSelector" SelectionChanged="WindowSelectionChanged" />
<TextBox Grid.Column="1" Grid.Row="0" Height="32" Width="300" HorizontalAlignment="Right" VerticalContentAlignment="Center" x:Name="SearchBox" HorizontalContentAlignment="Right" TextChanged="SearchBox_TextChanged"></TextBox>
<Button Grid.Column="2" Grid.Row="0" HorizontalContentAlignment="Center">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE713;" />

View File

@ -97,19 +97,21 @@ namespace ShortcutGuide
{
if (item == ManifestInterpreter.GetIndexYamlFile().DefaultShellName)
{
WindowSelector.Items.Insert(0, new SelectorBarItem { Name = item, Text = "Windows", Icon = new FontIcon() { Glyph = "\xE770" } });
WindowSelector.Items.Add(new SelectorBarItem { Name = item, Text = "Windows", Icon = new FontIcon() { Glyph = "\xE770" } });
}
else
{
try
{
WindowSelector.Items.Add(new SelectorBarItem { Name = item, Text = ManifestInterpreter.GetShortcutsOfApplication(item).Name });
WindowSelector.Items.Add(new SelectorBarItem { Name = item, Text = ManifestInterpreter.GetShortcutsOfApplication(item).Name, Icon = new FontIcon { Glyph = "\uEB91" } });
}
catch (IOException)
{
}
}
}
WindowSelector.SelectedItem = WindowSelector.Items[0];
}
}

View File

@ -21,7 +21,7 @@ namespace ShortcutGuide
{
public sealed partial class ShortcutView : Page, INotifyPropertyChanged
{
private ShortcutList shortcutList = ManifestInterpreter.GetShortcutsOfApplication(ShortcutPageParameters.CurrentPageName);
private ShortcutFile shortcutList = ManifestInterpreter.GetShortcutsOfApplication(ShortcutPageParameters.CurrentPageName);
public ShortcutView()
{