Skip to content

feat(FileConverter): initial implementation of context menu file conversion (seeking feedback)#46786

Open
Pikachu-5 wants to merge 4 commits intomicrosoft:mainfrom
Pikachu-5:feature/file-converterclean
Open

feat(FileConverter): initial implementation of context menu file conversion (seeking feedback)#46786
Pikachu-5 wants to merge 4 commits intomicrosoft:mainfrom
Pikachu-5:feature/file-converterclean

Conversation

@Pikachu-5
Copy link
Copy Markdown

Summary of the Pull Request

This PR introduces an initial implementation of a FileConverter module for PowerToys, including context menu integration, build setup, and module wiring.

I worked on this on my own to try and move the feature forward and make something concrete that could be reviewed. I didn’t get prior approval before starting, so I completely understand if changes or direction adjustments are needed.

I had commented on #36807 earlier but didn’t get a response, so I went ahead and built a working version.

Related issues:


PR Checklist


What this PR does

  • Adds a working FileConverter flow through the Windows context menu
  • Sets up the module structure and integrates it into the build system
  • Centralizes constants (pipe names, JSON keys, format tokens)
  • Adds localization support using .resw
  • Cleans up and stabilizes the conversion engine
  • Improves the smoke test so it works reliably on modern Windows

Right now, this supports image conversion only.
If this direction is accepted, I was planning to extend it to:

  • Documents (PDF, MD, DOCX)
  • Media encoding (possibly reusing logic from Advanced Paste)

How it works (quick overview)

  • Context menu uses IExplorerCommand with a parent entry + subcommands
  • Selected files are passed via JSON over a named pipe
  • Module interface validates and dispatches the request
  • Conversion is handled using WIC (PNG, JPEG, BMP, TIFF, HEIF, WebP)

One important fix:

  • Avoided using ResourceLoader in the constructor to prevent a startup crash

I have attached a video for reference:

video.mp4

Validation

  • Built all FileConverter components (Debug x64)
  • Confirmed PowerToys launches without crashing
  • Ran smoke test → output file successfully created
  • Verified fallback COM path works when verbs aren’t exposed

You can also just:

  • Right click an image → use FileConverter → check output file

Notes / Trade-offs

  • Startup uses fallback strings instead of early localization (done to avoid crash risk)
  • Smoke test includes a COM fallback because Shell.Application is unreliable on newer Windows context menus

Files changed

  • dllmain.cpp (context menu + module interface)
  • FileConversionEngine.cpp / .h
  • Constants.h (new)
  • Project files (.vcxproj)
  • Resources.resw
  • run-shell-verb-smoke.ps1

What reviewers should focus on

  • Constructor safety (startup stability)
  • Context menu eligibility + payload handling
  • Conversion engine error handling
  • Smoke test fallback logic
  • Localization completeness

Moderator Verification Plan

Run these in order from repo root.

  1. Build FileConverterLib
  • build.cmd -Path src\modules\FileConverter\FileConverterLib -Configuration Debug -Platform x64
  1. Build FileConverterContextMenu
  • build.cmd -Path src\modules\FileConverter\FileConverterContextMenu -Configuration Debug -Platform x64
  1. Build FileConverterModuleInterface
  • build.cmd -Path src\modules\FileConverter\FileConverterModuleInterface -Configuration Debug -Platform x64
  1. Register context-menu package
  • pwsh -NoProfile -ExecutionPolicy Bypass -File pack-contextmenu-msix.ps1 -Platform x64 -Configuration Debug -UseDevIdentity -DevPublisher "CN=PowerToys-Dev" -CreateDevCertificate -SignPackage -RegisterPackage
  1. Launch Runner
  • PowerToys.exe
  • Expected: process stays running.
  1. Run smoke
  • pwsh -NoProfile -ExecutionPolicy Bypass -File run-shell-verb-smoke.ps1
  • Expected:
  • Either direct verb invoke success, or
  • Verb not found followed by fallback invoke success
  • Output file created at sample_converted.png
  1. Optional sanity
  • Verify created file exists and nonzero size.
  • Confirm no new crash dump generated for PowerToys.exe during launch.

@Pikachu-5
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Pikachu-5 Pikachu-5 marked this pull request as ready for review April 5, 2026 19:56
Copilot AI review requested due to automatic review settings April 5, 2026 19:56
@Pikachu-5
Copy link
Copy Markdown
Author

Hello. I understand that this wasn’t discussed beforehand.

But seeing many issues talking about it and no one taking on the job, i decided to work on it myself. I’m happy to:

  • adjust the approach
  • split the PR
  • or align with suggested design

Looking forward to your feedback

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Initial end-to-end implementation of a new FileConverter PowerToys module, adding a File Explorer context-menu entry that sends selected files to the Runner via a named pipe and performs image format conversion via WIC, with Settings UI integration and verification scripts.

Changes:

  • Wires a new FileConverter module into Runner (module loading + settings window routing) and Settings UI (navigation + enable toggle).
  • Adds FileConverter module components: conversion engine (WIC), module interface (pipe listener/dispatcher), and context-menu COM server (IExplorerCommand + legacy IContextMenu).
  • Adds packaging/verification scripts (sparse package MSIX packing + smoke/negative tests) and module/localization resources.

Reviewed changes

Copilot reviewed 38 out of 47 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tools/Verification scripts/FileConverter/phase6-format-matrix-smoke.ps1 Adds a format matrix smoke test that exercises multiple destinations via the named pipe.
tools/Verification scripts/FileConverter/phase3-queue-smoke.ps1 Adds a queueing smoke test sending multiple requests to the named pipe.
tools/Verification scripts/FileConverter/negative-pipe-smoke.ps1 Adds negative test cases for malformed/invalid pipe payloads.
src/settings-ui/Settings.UI/ViewModels/FileConverterViewModel.cs Adds Settings UI ViewModel to toggle FileConverter enabled state via general settings IPC.
src/settings-ui/Settings.UI/Strings/en-us/Resources.resw Adds Settings UI strings for FileConverter module title and shell navigation label.
src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml Adds FileConverter entry to the Settings navigation view.
src/settings-ui/Settings.UI/SettingsXAML/Views/FileConverterPage.xaml.cs Adds Settings page code-behind for FileConverter (view model wiring + refresh hook).
src/settings-ui/Settings.UI/SettingsXAML/Views/FileConverterPage.xaml Adds Settings page UI for enabling FileConverter.
src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs Adds Settings page routing for “FileConverter”.
src/settings-ui/Settings.UI/Helpers/ModuleGpoHelper.cs Adds module type mapping for FileConverter (GPO unavailable + page type).
src/settings-ui/Settings.UI.Library/Helpers/ModuleHelper.cs Adds FileConverter module icon mapping, enablement mapping, and module key mapping.
src/settings-ui/Settings.UI.Library/EnabledModules.cs Adds FileConverter enable flag to General Settings enabled-modules model.
src/runner/settings_window.h Adds FileConverter to the settings window enum.
src/runner/settings_window.cpp Adds string <-> enum conversion for FileConverter settings window name.
src/runner/powertoy_module.cpp Adjusts module DLL loading to retry with an exe-relative path when LoadLibrary fails.
src/runner/main.cpp Adds FileConverter module interface DLL to the known modules list.
src/modules/FileConverter/Strings/en-us/Resources.resw Adds FileConverter module strings (context menu labels + error text + engine messages).
src/modules/FileConverter/FileConverterModuleInterface/pch.h Adds PCH for the module interface project.
src/modules/FileConverter/FileConverterModuleInterface/pch.cpp Adds PCH translation unit for the module interface project.
src/modules/FileConverter/FileConverterModuleInterface/FileConverterModuleInterface.vcxproj Adds build project for the module interface DLL.
src/modules/FileConverter/FileConverterModuleInterface/dllmain.cpp Implements module interface: context menu registration + named pipe listener + dispatch to conversion engine.
src/modules/FileConverter/FileConverterLib/pch.h Adds PCH for the conversion library project.
src/modules/FileConverter/FileConverterLib/pch.cpp Adds PCH translation unit for the conversion library project.
src/modules/FileConverter/FileConverterLib/FileConverterLib.vcxproj Adds static library project for the conversion engine/constants.
src/modules/FileConverter/FileConverterLib/FileConversionEngine.h Declares WIC-based conversion API + format enum + result structure.
src/modules/FileConverter/FileConverterLib/FileConversionEngine.cpp Implements WIC decoder/encoder conversion logic and encoder availability checks.
src/modules/FileConverter/FileConverterLib/Constants.h Adds shared constants for pipe name, JSON keys, format tokens, and extensions.
src/modules/FileConverter/FileConverterContextMenu/Source.def Exports COM entrypoints for the context menu DLL.
src/modules/FileConverter/FileConverterContextMenu/run-shell-verb-smoke.ps1 Adds smoke test to invoke the context menu verb (Shell.Application + IExplorerCommand fallback).
src/modules/FileConverter/FileConverterContextMenu/pch.h Adds PCH for the context menu project.
src/modules/FileConverter/FileConverterContextMenu/pch.cpp Adds PCH translation unit for the context menu project.
src/modules/FileConverter/FileConverterContextMenu/pack-contextmenu-msix.ps1 Adds packaging/signing/registration script for the sparse MSIX context menu package.
src/modules/FileConverter/FileConverterContextMenu/framework.h Adds context menu project includes for COM/shell APIs.
src/modules/FileConverter/FileConverterContextMenu/FileConverterContextMenu.vcxproj Adds build project for the context menu COM server DLL and assets/manifest inputs.
src/modules/FileConverter/FileConverterContextMenu/dllmain.cpp Implements IExplorerCommand-based context menu with subcommands and pipe payload emission.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/Wide310x150Logo.png Adds sparse package tile asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/storelogo.png Adds sparse package store logo asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/Square44x44Logo.png Adds sparse package tile asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/Square150x150Logo.png Adds sparse package tile asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/SplashScreen.png Adds sparse package splash asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/SmallTile.png Adds sparse package tile asset.
src/modules/FileConverter/FileConverterContextMenu/Assets/FileConverter/LargeTile.png Adds sparse package tile asset.
src/modules/FileConverter/FileConverterContextMenu/AppxManifest.xml Adds sparse package manifest for Win11 context menu registration.
src/common/ManagedCommon/ModuleType.cs Adds FileConverter to the shared module type enum.
PowerToys.slnx Adds FileConverter projects to the solution build/dependency graph.
doc/images/disk-usage/add_remove_size_v0.66_converted.jpeg Adds a converted JPEG image under docs (appears unrelated to FileConverter feature).

@jiripolasek
Copy link
Copy Markdown
Collaborator

@Pikachu-5
Copy link
Copy Markdown
Author

Hey, thanks for pointing me to this.

Yes, I realize I should’ve discussed it first. I mostly built this to try out the idea and see if it’s actually workable.

I’m happy to move the discussion to the issue or adjust this PR however you’d prefer. Just let me know what makes the most sense from your side.

@Pikachu-5
Copy link
Copy Markdown
Author

Ready for review! I've fixed the issues Copilot caught and did a bit of housecleaning. I realized I mistakenly committed the nlohmann library headers in the previous commit, so I've stripped those out to keep the PR focused. Everything should be good to go now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Would like something to convert an image's file extension to something else Feature Request: Power File Converter Tool

3 participants