Compare commits

..

79 Commits

Author SHA1 Message Date
Stefan Markovic
dae659218c WIP 2024-01-03 10:55:18 +01:00
Stefan Markovic
eaa385b5b3 Remove global.json 2024-01-02 22:21:04 +01:00
Niels Laute
86931076ee Updating icon 2024-01-02 14:33:16 +01:00
Stefan Markovic
fc1d1b80c9 minor fixes 2024-01-02 14:05:31 +01:00
Stefan Markovic
07545de686 Fix build 2024-01-02 13:01:13 +01:00
Stefan Markovic
c7903dce17 Fix sln file 2024-01-02 12:39:46 +01:00
Stefan Markovic
6e682d3a27 Merge remote-tracking branch 'origin/main' into dev/cazamor/cmd-not-found 2024-01-02 12:11:28 +01:00
Stefan Markovic
433733d815 Merge branch 'dev/cazamor/cmd-not-found' of https://github.com/microsoft/PowerToys into dev/cazamor/cmd-not-found 2024-01-02 12:07:54 +01:00
Stefan Markovic
15326f8621 Add telemetry for suggestions and feedbacks 2024-01-02 09:44:04 +01:00
Niels Laute
274cc2fab1 Update settings UI and strings 2023-12-29 21:17:26 +01:00
Niels Laute
4e2d8d5d98 Adding icons 2023-12-29 20:35:50 +01:00
Stefan Markovic
7d3451101c If GPO is set, disable Settings page logic 2023-12-29 12:23:44 +01:00
Stefan Markovic
c674fee8f7 Cleanup settings code 2023-12-29 12:23:10 +01:00
Stefan Markovic
a988f5597c Cleanup module interface 2023-12-29 12:22:45 +01:00
Stefan Markovic
797a645f93 If GPO is set, enable/disable module on PT start depending on gpo value 2023-12-29 12:22:19 +01:00
Stefan Markovic
7e438a7e12 Fix gpo files 2023-12-29 12:21:25 +01:00
Stefan Markovic
cf7850dbfa Add telemetry events 2023-12-28 17:51:55 +01:00
gokcekantarci
a94b3eec39 .NET 8 Upgrade Silenced Errors Fix (#30469)
* [Dev][Build] .NET 8 Upgrade Silenced errors first fix.

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1859

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1854.

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1860

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1861

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1862

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1863

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1864

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1865

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA2208

* [Dev][Build] .NET 8 Upgrade Silenced errors. CS9191

* [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check

* [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check

* [Dev][Build] .NET 8 Upgrade Silenced errors.
- CompositeFormat variables used more than once in the same file were assigned to a single variable.
- GetProcessesByName logic fix.
- String comparion fix.
- ArgumentOutOfRangeException message change.

* [Dev][Build] .NET 8 Upgrade Silenced errors.
- Null check added.
- static readonly CompositeFormat added for all fields.
2023-12-28 13:37:13 +03:00
gokcekantarci
cd57659ef6 [Common] Move Elevated Apps Warning and Add Warning for AlwaysOnTop (#30607)
* [Common] - Elevated apps warning moved to common notifications
- Warning added to AoT

* [Common] Build fix.

* [Common] Moved strings from common to AoT.

* [Common] Show notification fix.

* [Common] String name changed.

* [Common] Remove blank space

* [Common] Remove blank space

* [Common] Remove blank space
2023-12-28 13:33:04 +03:00
Davide Giacometti
740299189a [Run] Fix plugins selection style (#30546)
* fix plugin selection style

* addressed feedbacks and tweaks
2023-12-27 18:26:54 +01:00
Niels Laute
ccd401fc16 [Run] Adding configurable fontsizes (#30541)
* Adding configurable fontsize for result titles

* Update src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Updating strings

* XAML styler

* CI fix

* PowerLauncher images

* update results height on font change

* Revert "update results height on font change"

This reverts commit 459f57c647.

---------

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2023-12-26 14:49:50 +01:00
coreyH
c098cfb193 [PTRun] PowerToys Run - plugin dependency loading (#30513)
* Updated the Wox.Plugin to correctly load and resolve plugin dependecies

* Included new plugin.props in all plugins to enable dynamic dependecy loading

* Updated dev docs to include new plugin.props in plugins

* Fixed double dependecy loading bug

* - Updated to only use dynamic loading when explicitly set by the plugin.
- Removed no longer required props from default plugins which do not need dynamic loading.
- Updated dev-docs to align with latest changes

* Removed line spacing changes in plugins csproj

* fixed spelling

* csproj cleanup

* removed unnecessary null checking

---------

Co-authored-by: Corey Hayward <coreyh@tigereyeconsulting.com>
2023-12-26 10:19:15 +01:00
Niels Laute
3e45392274 [Settings] Fix "What's new" icon (#30557)
* Fixing order and icon

* XAML styler

* Fix expect
2023-12-25 18:31:07 +01:00
Jaime Bernardo
b39d60a906 Fix spellcheck 2023-12-22 23:41:19 +00:00
Jaime Bernardo
881364fa0a Fix psd1 file resolution when installed 2023-12-22 23:36:43 +00:00
Jaime Bernardo
19d409afec installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound 2023-12-22 22:46:46 +00:00
Jaime Bernardo
36e2417390 Consistent install module scripts location on debug and installed 2023-12-22 22:46:10 +00:00
Jaime Bernardo
5cb395b1d4 Don't remove CmdNotFound on upgrade and don't fail on uninstall of
CmdNotFound
2023-12-22 22:04:36 +00:00
Jaime Bernardo
1604287fbb Fix image files and placeholders 2023-12-22 22:01:23 +00:00
Jaime Bernardo
b4615ab75d Fix spellcheck 2023-12-22 21:13:02 +00:00
Jaime Bernardo
91aaa938c1 Make module enable and disable scripts give better information 2023-12-22 17:05:59 +00:00
Jaime Bernardo
da05364b78 Fix PowerShell 7 output 2023-12-22 15:44:34 +00:00
Jaime Bernardo
26f5a4c9c6 Fix Settings Assets paths 2023-12-22 15:21:19 +00:00
Jaime Bernardo
7150aa3788 Add button to check PowerShell 7's version 2023-12-22 15:11:54 +00:00
Jaime Bernardo
2796799e51 Prettify the Settings controls 2023-12-22 15:05:11 +00:00
Jaime Bernardo
5fa7b73305 Give the user some output from installing 2023-12-22 14:06:21 +00:00
Jaime Bernardo
411121c7b6 Fix styling 2023-12-21 20:59:59 +00:00
Davide Giacometti
ae21b0dc09 [Run] Switch to WPF UI theme manager (#30520)
* Switch to WPF UI theme manager

* fix

* add theme manager

* fix

* fix

* update error icon

* moved image initialization

* cleanup
2023-12-21 13:56:48 +01:00
Davide Giacometti
e73e73fa6c [PTRun]Allow interaction with plugin hints (#30531) 2023-12-20 15:19:58 +00:00
Clint Rutkas
0e01314bbd [Docs]Add code comment to not upgrade Moq due to behavior change (#30506) 2023-12-20 11:13:06 +00:00
Quriz
451607e412 [Docs]Add Scoop plugin to thirdPartyRunPlugins.md (#30493)
* Add Scoop plugin to thirdPartyRunPlugins.md
2023-12-19 18:51:11 +00:00
Jaime Bernardo
e47f1b8cec [ci]Update sdl baselines after boost upgrade (#30526) 2023-12-19 16:33:59 +00:00
Niels Laute
af099737b8 [Run] UI improvements + ability to show/hide plugins overview panel (#30258)
* Add setting to show/hide plugin keywords in Run

* Increasing fontsize and spacing

* Removing tooltip prefixes

* Tweaks and making sure the window gets smaller when plugins overview is disabled

* Label updates for Settings

* Updating UI

* Fix number of results height

* Centering textbox

* Adding tooltip to keyword

* Selection highlight + dark theme tweaks

* Change order and fix CI

* Update expect.txt

* Add option to select only non-global plugins preview

* Fix typos

---------

Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2023-12-19 14:11:35 +01:00
Stefan Markovic
b390484fd8 Installer. Add DisableModule.ps1 2023-12-19 00:22:59 +01:00
Clint Rutkas
545f901492 [Deps]Upgrading STL Thumbnail provider to latest (Helix package) (#30505)
* upgraded to latest

* Fix NOTICE.md

* Fix dependency conflict

* Actually reference abstractions dependency
2023-12-18 22:30:48 +00:00
Quyen Le Van
3299ecfece [FancyZones]Keep maximized state when moving new window to active monitor (#28688) 2023-12-18 16:04:46 +00:00
Pedro Lamas
4c3e5348f0 [Peek]Adds QOI file support (#29919)
* Adds QOI support to Peek

* Reduce allocations on QoiImage

* Add to QOI to Peek's NOTICE as well.

* Ensure file stream is closed after reading QOI
2023-12-18 15:54:17 +00:00
Clint Rutkas
ee22581913 [Deps]Upgrade boost to 1.84 (#30504)
* Upgrading boost
2023-12-18 13:32:27 +00:00
Clint Rutkas
f28f52015e [Deps]Consolidate Microsoft.Windows.SDK.BuildTools(#30503) 2023-12-18 11:09:08 +00:00
Clint Rutkas
1d1bac0b3b [Docs]Update README.md to directly state x64 & ARM64 requirement (#30476) 2023-12-18 11:07:59 +00:00
Stefan Markovic
73f6993ea0 Merge remote-tracking branch 'origin/main' into dev/cazamor/cmd-not-found 2023-12-18 11:16:13 +01:00
Stefan Markovic
aa4bdfe7fb spellcheck again 2023-12-15 14:05:58 +01:00
Stefan Markovic
53d5550b19 spellcheck 2023-12-15 13:58:17 +01:00
Stefan Markovic
970607a841 Add EnableModule.ps1 2023-12-15 13:50:29 +01:00
PesBandi
bf7462b196 Update Resources.resx (#30449) 2023-12-15 13:33:04 +01:00
Stefan Markovic
eb77c04ea2 WIP trying to import module from settings 2023-12-14 17:25:44 +01:00
Stefan Markovic
c7372b6c40 Update hashes - 76.2 (#30422) 2023-12-13 11:28:22 -08:00
Stefan Markovic
d1c6adbef8 Merge remote-tracking branch 'origin/main' into dev/cazamor/cmd-not-found 2023-12-13 12:48:59 +01:00
Stefan Markovic
063a4366bf Bump WPF-UI package version (#30411)
* Bump WPF-UI package version

* Update notice.md
2023-12-13 11:28:54 +01:00
Stefan Markovic
415843f6f4 Add --disable-features=RendererAppContainer WebView2Environment option (#30412) 2023-12-13 11:12:31 +01:00
Stefan Markovic
bca8f4d3ee Add module interface 2023-12-12 14:17:23 +01:00
gokcekantarci
1daeba7e77 [EnvironmentVariables] EnvironmentVariables window set to front when launched. (#30226)
* [EnvironmentVariables] EnvironmentVariables window set to front when launched.

* [EnvironmentVariables] BringToForeground function used instead of SetForegroundWindow.

* [EnvironmentVariables] BringToForeground is moved to MainWindow constructor.

* [EnvironmentVariables] Move 'handle' from class field to local variable in MainWindow constructor.
2023-12-12 14:15:26 +01:00
Niels Laute
cc605113cf Fix reportwindow in dark mode (#30387) 2023-12-12 14:14:44 +01:00
PesBandi
3f54968d8c Move Greek letters with tonos from Get...AllLanguagesOnly to Get...EL (Greek) (#30307) 2023-12-11 22:03:34 +01:00
Aaron Junker-Wildi
a4260d7cbd Add information about how to add new languages to monaco (#24906)
* Add information about how to add new languages to monaco

* Update expect.txt

* Update doc/devdocs/modules/FileExplorer/monaco/readme.md

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Adress PR feedback

* fix spelling errors

* Update doc/devdocs/modules/FileExplorer/monaco/readme.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update readme.md

* Update readme.md

* Address PR comments

* Fix spelling

* address PR comments

* address PR comments and move files

* Update expect.txt

* Update doc/devdocs/common/readme.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>

* Adress PR comments

* Fix spelling

* Adress PR comments

* Add peek stub documentation

* Update doc/devdocs/common/FilePreviewCommon.md

Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>

* Update doc/devdocs/common/FilePreviewCommon.md

* Fix spelling

---------

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
2023-12-11 16:45:16 +01:00
Stefan Markovic
93a422ca9b [Settings] Fix reacting to theme change (#30326) 2023-12-11 16:44:53 +01:00
Stefan Markovic
48ac5d58fb Merge remote-tracking branch 'origin/main' into dev/cazamor/cmd-not-found 2023-12-10 12:58:12 +01:00
Davide Giacometti
f30438b959 set window icon/title and use centralized logger (#30091) 2023-12-09 13:15:24 +01:00
Davide Giacometti
9e03386eb3 [Run] XamlStyler formatting (#30011)
* XamlStyler formatting

* remove unused theme files

* fix formatting
2023-12-08 14:57:42 +01:00
Seraphima Zykova
b3804a9f38 fix excluded apps check (#30138) 2023-12-08 12:48:36 +01:00
Clint Rutkas
3e7cc723a5 update hashes to 76.1 (#30264) 2023-12-07 11:34:30 -08:00
Carlos Zamora
9e67672265 add warm up; implement IPooledObjectPolicy 2023-09-25 11:08:47 -07:00
Carlos Zamora
1a04698878 apply Dongbo's feedback 2023-09-22 15:54:41 -07:00
Carlos Zamora
37ec988257 add and use object pool 2023-09-22 14:05:42 -07:00
Carlos Zamora
9b5221519d fix SUI build; try and store PowerShell object 2023-09-19 16:47:01 -07:00
Carlos Zamora
008484131a try and implement settings UI 2023-09-15 17:42:36 -07:00
Carlos Zamora
ef7aea0f3d address Dongbo's feedback 2023-09-08 15:01:51 -07:00
Carlos Zamora
9c2dd30060 rewrite module to depend on WinGet PowerShell module 2023-09-07 11:13:26 -07:00
Carlos Zamora
784e4e4d43 Introduce Command Not Found module 2023-09-07 11:12:37 -07:00
292 changed files with 5399 additions and 1454 deletions

View File

@@ -94,6 +94,7 @@ peteblois
phoboslab
Ponten
Pooja
Quriz
randyrants
ricardosantos
robmikh

View File

@@ -1,3 +1,6 @@
# FALSE POSITIVES
## "PackagemanagerWrapper.cs" should be "PackageManagerWrapper.cs"
## NOTICE.MD > MOZILLA PUBLIC LICENSE v1.1
aaaa
abcdefghjkmnpqrstuvxyz
abgr
@@ -34,6 +37,7 @@ ALPHATYPE
AModifier
AMPROPERTY
AMPROPSETID
animatedvisuals
ANDSCANS
ansicolor
ANull
@@ -160,7 +164,6 @@ CHANGECBCHAIN
changecursor
CHILDACTIVATE
CHILDWINDOW
CHT
cidl
cim
CImage
@@ -181,6 +184,7 @@ clrcall
CLSCTX
Clusion
cmder
CMDNOTFOUNDMODULEINTERFACE
Cmds
CMIC
CMINVOKECOMMANDINFO
@@ -218,7 +222,6 @@ CONFIGW
CONFLICTINGMODIFIERKEY
CONFLICTINGMODIFIERSHORTCUT
CONOUT
constexpr
consts
contentdialog
contentfiles
@@ -295,6 +298,7 @@ ddf
DDxgi
Deact
debugbreak
declatory
decryptor
Dedup
DEFAULTBOOTSTRAPPERINSTALLFOLDER
@@ -318,7 +322,6 @@ DESKTOPABSOLUTEEDITING
DESKTOPABSOLUTEPARSING
desktopshorcutinstalled
desktopwindowxamlsource
DEU
devblogs
devdocs
devenum
@@ -537,7 +540,6 @@ Hanzi
Hardlines
hardlinks
HARDWAREINPUT
hashcode
Hashset
hashtag
HASHVAL
@@ -556,7 +558,6 @@ hcwhite
hdc
hdrop
hdwwiz
HEB
Helpline
helptext
HGFE
@@ -719,7 +720,6 @@ jif
jjw
jobject
jpe
JPN
jpnime
Jsons
jsonval
@@ -745,6 +745,7 @@ killrunner
Knownfolders
KSPROPERTY
Kybd
languagesjson
lastcodeanalysissucceeded
Lastdevice
LAYOUTRTL
@@ -902,6 +903,8 @@ MOUSEHWHEEL
MOUSEINPUT
MOVESIZEEND
MOVESIZESTART
MOZILLAPL
MOZPL
mpmc
MRM
MRT
@@ -967,6 +970,7 @@ newdev
newitem
newpath
newrow
newsgroups
NIF
NLD
NLog
@@ -979,7 +983,6 @@ NOCLOSEPROCESS
NOCOALESCE
NOCOPYBITS
nodeca
nodiscard
nodoc
NODRAWCAPTION
NODRAWICON
@@ -1016,6 +1019,7 @@ NOTSRCCOPY
NOTSRCERASE
NOZORDER
NPH
npmjs
NResize
nrw
nsunt
@@ -1065,6 +1069,7 @@ overlaywindow
Oversampling
OWNDC
OWNERDRAW
Packagemanager
PACL
PAINTSTRUCT
PALETTEWINDOW
@@ -1087,7 +1092,6 @@ pcch
pcelt
pch
PCIDLIST
pcs
PCWSTR
pdisp
pdo
@@ -1212,6 +1216,7 @@ QITAB
QITABENT
qoi
qps
Quarternary
QUERYENDSESSION
QUERYOPEN
QUEUESYNC
@@ -1297,7 +1302,6 @@ RKey
RNumber
roadmap
rop
roundf
ROUNDSMALL
rpcrt
RRF
@@ -1313,12 +1317,11 @@ rundll
rungameid
RUNLEVEL
runsettings
runspace
runtimeclass
runtimeobject
runtimepack
runtimes
RUS
RValue
rvm
rwin
rwl
@@ -1499,7 +1502,6 @@ subquery
Superbar
sut
svchost
SVE
SVGIn
SVGIO
svgz
@@ -1572,7 +1574,6 @@ tlbimp
TMPVAR
TNP
toggleswitch
tonos
toolkitcontrols
toolkitconverters
Toolset
@@ -1708,6 +1709,7 @@ wcsnicmp
WDA
wdp
wdupenv
webbrowsers
webcam
webpage
websites
@@ -1715,7 +1717,6 @@ wekyb
Wevtapi
wgpocpl
WIC
wifi
wil
winapi
winappdriver
@@ -1843,13 +1844,3 @@ zonable
zoneset
Zoneszonabletester
zzz
newsgroups
MOZILLAPL
MOZPL
# FALSE POSITIVES
## NOTICE.MD > MOZILLA PUBLIC LICENSE v1.1
declatory
## "PackagemanagerWrapper.cs" should be "PackageManagerWrapper.cs"
Packagemanager

View File

@@ -118,6 +118,9 @@ aka\.ms/[a-zA-Z0-9]+
# YouTube url
\b(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|user/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_%]*
# power shell gallery website
\bpowershellgallery.com/[-_a-zA-Z0-9()=./%]*
# uuid: (or CompGUIDPrefix)
L?(["']|[-<({>]|\b)[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{10,12}(?:\g{-1}|[<})>])

View File

@@ -28,7 +28,10 @@
"PowerToys.AlwaysOnTop.exe",
"PowerToys.AlwaysOnTopModuleInterface.dll",
"PowerToys.CmdNotFoundModuleInterface.dll",
"PowerToys.CommandNotFound.dll",
"PowerToys.ColorPicker.dll",
"PowerToys.ColorPickerUI.dll",
"PowerToys.ColorPickerUI.exe",

View File

@@ -107,7 +107,7 @@ if (-not $Passive)
else
{
Write-Output "Checking all files (passively)"
$files = Get-ChildItem -Path "$PSScriptRoot\..\src\*.xaml" -Recurse | Select-Object -ExpandProperty FullName | Where-Object { $_ -notmatch "(\\obj\\)|(\\bin\\)|(\\x64\\)|(\\Generated Files\\PowerRenameXAML\\)|(\\launcher\\PowerLauncher\\)|(\\launcher\\Wox.Plugin\\)|(\\colorPicker\\ColorPickerUI\\)" }
$files = Get-ChildItem -Path "$PSScriptRoot\..\src\*.xaml" -Recurse | Select-Object -ExpandProperty FullName | Where-Object { $_ -notmatch "(\\obj\\)|(\\bin\\)|(\\x64\\)|(\\Generated Files\\PowerRenameXAML\\)|(\\colorPicker\\ColorPickerUI\\)" }
if ($files.count -gt 0)
{

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Appium.WebDriver" Version="4.2.1" />
<PackageVersion Include="Cake.Powershell" Version="3.0.0" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.0.230907" />
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.230907" />
@@ -18,20 +19,23 @@
<PackageVersion Include="ControlzEx" Version="6.0.0" />
<PackageVersion Include="coverlet.collector" Version="1.3.0" />
<PackageVersion Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageVersion Include="HelixToolkit" Version="2.20.2" />
<PackageVersion Include="HelixToolkit.Core.Wpf" Version="2.20.2" />
<PackageVersion Include="HelixToolkit" Version="2.24.0" />
<PackageVersion Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
<PackageVersion Include="hyjiacan.pinyin4net" Version="4.1.1" />
<PackageVersion Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0.2" />
<PackageVersion Include="LazyCache" Version="2.4.0" />
<PackageVersion Include="Mages" Version="2.0.1" />
<PackageVersion Include="Markdig.Signed" Version="0.27.0" />
<PackageVersion Include="Markdig.Signed" Version="0.30.4" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.336902" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="7.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.2088.41" />
@@ -45,10 +49,11 @@
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageVersion Include="ModernWpfUI" Version="0.9.4" />
<!-- Moq to stay below v4.20 due to behavior change. need to be sure fixed -->
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Include="NLog" Version="5.0.4" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.0.4" />
<PackageVersion Include="NLog.Schema" Version="5.0.4" />
@@ -64,6 +69,7 @@
<PackageVersion Include="System.IO.Abstractions" Version="17.2.3" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
<PackageVersion Include="System.Management" Version="8.0.0" />
<PackageVersion Include="System.Management.Automation" Version="7.4.0-preview.3" />
<PackageVersion Include="System.Reactive" Version="6.0.0-preview.9" />
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0" />
<PackageVersion Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
@@ -74,11 +80,11 @@
<PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" />
<PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" />
<PackageVersion Include="WinUIEx" Version="2.2.0" />
<PackageVersion Include="WPF-UI" Version="3.0.0-preview.11" />
<PackageVersion Include="WPF-UI" Version="3.0.0-preview.12" />
</ItemGroup>
<ItemGroup Condition="'$(IsExperimentationLive)'!=''">
<!-- Additional dependencies used by experimentation -->
<PackageVersion Include="Microsoft.VariantAssignment.Client" Version="2.4.17140001" />
<PackageVersion Include="Microsoft.VariantAssignment.Contract" Version="3.0.16990001" />
</ItemGroup>
</Project>
</Project>

View File

@@ -788,6 +788,34 @@ SOFTWARE.
## Utility: Peek
### The Quite OK Image Format reference decoder
**Source**: https://github.com/phoboslab/qoi
**Note**: [@pedrolamas](https://github.com/pedrolamas) translated and adapted the reference decoder code to C# that is in PowerToys from the original C++ implementation.
MIT License
Copyright (c) 2022 Dominic Szablewski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
### UTF Unknown
We use the UTF.Unknown NuGet package for detecting encoding in text/code files.
@@ -1279,8 +1307,8 @@ EXHIBIT A -Mozilla Public License.
- CommunityToolkit.WinUI.UI.Controls.DataGrid 7.1.2
- CommunityToolkit.WinUI.UI.Controls.Markdown 7.1.2
- ControlzEx 6.0.0
- HelixToolkit 2.20.2
- HelixToolkit.Core.Wpf 2.20.2
- HelixToolkit 2.24.0
- HelixToolkit.Core.Wpf 2.24.0
- hyjiacan.pinyin4net 4.1.1
- Interop.Microsoft.Office.Interop.OneNote 1.1.0.2
- LazyCache 2.4.0
@@ -1292,6 +1320,7 @@ EXHIBIT A -Mozilla Public License.
- Microsoft.Extensions.Hosting 8.0.0
- Microsoft.Extensions.Hosting.WindowsServices 8.0.0
- Microsoft.Extensions.Logging 8.0.0
- Microsoft.Extensions.Logging.Abstractions 8.0.0
- Microsoft.NET.Test.Sdk 17.6.3
- Microsoft.Toolkit.Uwp.Notifications 7.1.2
- Microsoft.Web.WebView2 1.0.2088.41
@@ -1331,5 +1360,5 @@ EXHIBIT A -Mozilla Public License.
- Vanara.PInvoke.Shell32 3.4.11
- Vanara.PInvoke.User32 3.4.11
- WinUIEx 2.2.0
- WPF-UI 3.0.0-preview.11
- WPF-UI 3.0.0-preview.12

View File

@@ -538,6 +538,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLock", "src\modules\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CmdNotFound", "src\modules\cmdNotFound\CmdNotFound\CmdNotFound.csproj", "{A37865FE-2881-449F-8ADB-B8CD373D6D79}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cmdNotFound", "cmdNotFound", "{4C0D0746-BE5B-49EE-BD5D-A7811628AE8B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-FancyZonesEditor", "src\modules\fancyzones\UnitTests-FancyZonesEditor\UnitTests-FancyZonesEditor.csproj", "{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EnvironmentVariables", "EnvironmentVariables", "{538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}"
@@ -558,6 +562,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-QoiPreviewHandler
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-QoiThumbnailProvider", "src\modules\previewpane\UnitTests-QoiThumbnailProvider\UnitTests-QoiThumbnailProvider.csproj", "{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmdNotFoundModuleInterface", "src\modules\cmdNotFound\CmdNotFoundModuleInterface\CmdNotFoundModuleInterface.vcxproj", "{0014D652-901F-4456-8D65-06FC5F997FB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
@@ -2328,6 +2334,18 @@ Global
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x64.Build.0 = Release|x64
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.ActiveCfg = Release|x64
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.Build.0 = Release|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|ARM64.ActiveCfg = Debug|ARM64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|ARM64.Build.0 = Debug|ARM64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|x64.ActiveCfg = Debug|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|x64.Build.0 = Debug|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|x86.ActiveCfg = Debug|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Debug|x86.Build.0 = Debug|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|ARM64.ActiveCfg = Release|ARM64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|ARM64.Build.0 = Release|ARM64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|x64.ActiveCfg = Release|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|x64.Build.0 = Release|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|x86.ActiveCfg = Release|x64
{A37865FE-2881-449F-8ADB-B8CD373D6D79}.Release|x86.Build.0 = Release|x64
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.Build.0 = Debug|ARM64
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x64.ActiveCfg = Debug|x64
@@ -2436,6 +2454,18 @@ Global
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x64.Build.0 = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x86.ActiveCfg = Release|x64
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}.Release|x86.Build.0 = Release|x64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|ARM64.ActiveCfg = Debug|ARM64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|ARM64.Build.0 = Debug|ARM64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|x64.ActiveCfg = Debug|x64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|x64.Build.0 = Debug|x64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|x86.ActiveCfg = Debug|Win32
{0014D652-901F-4456-8D65-06FC5F997FB0}.Debug|x86.Build.0 = Debug|Win32
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|ARM64.ActiveCfg = Release|ARM64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|ARM64.Build.0 = Release|ARM64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|x64.ActiveCfg = Release|x64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|x64.Build.0 = Release|x64
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|x86.ActiveCfg = Release|Win32
{0014D652-901F-4456-8D65-06FC5F997FB0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -2630,6 +2660,8 @@ Global
{3B227528-4BA6-4CAF-B44A-A10C78A64849} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{F5E1146E-B7B3-4E11-85FD-270A500BD78C} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
{3157FA75-86CF-4EE2-8F62-C43F776493C6} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
{A37865FE-2881-449F-8ADB-B8CD373D6D79} = {4C0D0746-BE5B-49EE-BD5D-A7811628AE8B}
{4C0D0746-BE5B-49EE-BD5D-A7811628AE8B} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
{538ED0BB-B863-4B20-98CC-BCDF7FA0B68A} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{51465DA1-C18B-4B99-93E1-ECF8E0FA0CBA} = {538ED0BB-B863-4B20-98CC-BCDF7FA0B68A}
@@ -2640,6 +2672,7 @@ Global
{6B04803D-B418-4833-A67E-B0FC966636A5} = {2F305555-C296-497E-AC20-5FA1B237996A}
{3940AD4D-F748-4BE4-9083-85769CD553EF} = {2F305555-C296-497E-AC20-5FA1B237996A}
{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38} = {2F305555-C296-497E-AC20-5FA1B237996A}
{0014D652-901F-4456-8D65-06FC5F997FB0} = {4C0D0746-BE5B-49EE-BD5D-A7811628AE8B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}

View File

@@ -17,8 +17,8 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
| | Current utilities: | |
|--------------|--------------------|--------------|
| [Always on Top](https://aka.ms/PowerToysOverview_AoT) | [PowerToys Awake](https://aka.ms/PowerToysOverview_Awake) | [Color Picker](https://aka.ms/PowerToysOverview_ColorPicker) |
| [Crop And Lock](https://aka.ms/PowerToysOverview_CropAndLock) | [Environment Variables](https://aka.ms/PowerToysOverview_EnvironmentVariables) | [FancyZones](https://aka.ms/PowerToysOverview_FancyZones) |
| [Always on Top](https://aka.ms/PowerToysOverview_AoT) | [PowerToys Awake](https://aka.ms/PowerToysOverview_Awake) | [Command Not Found](https://aka.ms/PowerToysOverview_CmdNotFound) |
| [Color Picker](https://aka.ms/PowerToysOverview_ColorPicker) | [Crop And Lock](https://aka.ms/PowerToysOverview_CropAndLock) | [Environment Variables](https://aka.ms/PowerToysOverview_EnvironmentVariables) | [FancyZones](https://aka.ms/PowerToysOverview_FancyZones) |
| [File Explorer Add-ons](https://aka.ms/PowerToysOverview_FileExplorerAddOns) | [File Locksmith](https://aka.ms/PowerToysOverview_FileLocksmith) | [Hosts File Editor](https://aka.ms/PowerToysOverview_HostsFileEditor) |
| [Image Resizer](https://aka.ms/PowerToysOverview_ImageResizer) | [Keyboard Manager](https://aka.ms/PowerToysOverview_KeyboardManager) | [Mouse utilities](https://aka.ms/PowerToysOverview_MouseUtilities) |
| [Mouse Without Borders](https://aka.ms/PowerToysOverview_MouseWithoutBorders) | [Peek](https://aka.ms/PowerToysOverview_Peek) | [Paste as Plain Text](https://aka.ms/PowerToysOverview_PastePlain) |
@@ -31,6 +31,7 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline
### Requirements
- Windows 11 or Windows 10 version 2004 (code name 20H1 / build number 19041) or newer.
- x64 or ARM64 processor
- Our installer will install the following items:
- [Microsoft Edge WebView2 Runtime](https://go.microsoft.com/fwlink/p/?LinkId=2124703) bootstrapper. This will install the latest version.
@@ -41,17 +42,17 @@ Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and cl
<!-- items that need to be updated release to release -->
[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F50
[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F49
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.0/PowerToysUserSetup-0.76.0-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.0/PowerToysUserSetup-0.76.0-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.0/PowerToysSetup-0.76.0-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.0/PowerToysSetup-0.76.0-arm64.exe
[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.2/PowerToysUserSetup-0.76.2-x64.exe
[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.2/PowerToysUserSetup-0.76.2-arm64.exe
[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.2/PowerToysSetup-0.76.2-x64.exe
[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.76.2/PowerToysSetup-0.76.2-arm64.exe
| Description | Filename | sha256 hash |
|----------------|----------|-------------|
| Per user - x64 | [PowerToysUserSetup-0.76.0-x64.exe][ptUserX64] | 627F60BF3F04583A2ECE7ACE7E6F09ABDE92493E1FFFAC5705CC83009781CD8D |
| Per user - ARM64 | [PowerToysUserSetup-0.76.0-arm64.exe][ptUserArm64] | 79D11CDDBDD87DF8A69A5B2FC28869B3085392E5F45FEE6560D278E48F8B0673 |
| Machine wide - x64 | [PowerToysSetup-0.76.0-x64.exe][ptMachineX64] | 4F24A288AC92DD0AB74EF52CFE3D66FA744BDC6889CB4E3ED088763D9134C06D |
| Machine wide - ARM64 | [PowerToysSetup-0.76.0-arm64.exe][ptMachineArm64] | 1BD9CD9C696D8898AAEE5A6D6A7122F053202CF1865C511BFC91FCFD0D767864 |
| Per user - x64 | [PowerToysUserSetup-0.76.2-x64.exe][ptUserX64] | 73D734FC34B3F9D7484081EC0F0B6ACD4789A55203A185904CC5C62ABD02AF16 |
| Per user - ARM64 | [PowerToysUserSetup-0.76.2-arm64.exe][ptUserArm64] | 5284CC5DA399DC37858A2FD260C30F20C484BA1B5616D0EB67CD90A8A286CB8B |
| Machine wide - x64 | [PowerToysSetup-0.76.2-x64.exe][ptMachineX64] | 72B87381C9E5C7447FB59D7CE478B3102C9CEE3C6EB3A6BC7EC7EC7D9EFAB2A0 |
| Machine wide - ARM64 | [PowerToysSetup-0.76.2-arm64.exe][ptMachineArm64] | F28C7DA377C25309775AB052B2B19A299C26C41582D05B95C3492A4A8C952BFE |
This is our preferred method.

View File

@@ -0,0 +1,75 @@
# [FilePreviewCommon](/src/common/FilePreviewCommon)
This project contains common code used for previewing and displaying files.
## Monaco preview
Monaco preview enables to display developer files. It is based on [Microsoft's Monaco Editor](https://microsoft.github.io/monaco-editor/) which is maintained by the Visual Studio Code team.
This previewer is used for the File Explorer Dev File Previewer, as well as PowerToys Peek.
### Update Monaco Editor
1. Download Monaco editor with [npm](https://www.npmjs.com/): Run `npm i monaco-editor` in the command prompt.
2. Delete everything except the `min` folder (the minimised code) from the downloaded files.
3. Copy the `min` folder into the `src/common/FilePreviewCommon/Assets/Monaco/monacoSRC` folder of the PowerToys project.
4. Generate the JSON file as described in the generate [monaco_languages.json file](#monaco_languagesjson) section.
### Add a new language definition
As an example on how to add a new language definition you can look at the one for [registry files](/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/reg.js).
1. Add the new language definition (written with [Monarch](https://microsoft.github.io/monaco-editor/monarch.html)) as a new file to the [folder containing Monaco custom languages](/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/) (Remember the file name and the string you used for "idDefinition" as you need it later.). The file should be formatted like in the example below. (Please change `idDefinition` to the name of your language.)
```javascript
export function idDefinition() {
return {
...
}
}
```
2. Add the following line to the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file, after the other import statements:
```javascript
import { idDefinition } from './customLanguages/file.js';
```
> Replace file.js with the name of your definition file from step 1. Please replace idDefinition with the string you used in step 1.
3. In the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file add the following line into the `registerAdditionalLanguages` function:
```javascript
registerAdditionalNewLanguage("id", [".fileExtension"], idDefinition(), monaco)
```
> Replace id and idDefinition with your id and string used in step 1. Replace fileExtension with a set of file extensions you want the language to register to.
* The id can be anything. Recommended is one of the file extensions. For example "php" or "reg".
4. Execute the steps described in the [monaco_languages.json](#monaco_languagesjson) section.
### Add a new file extension to an existing language
1. In the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file add the following line to the `registerAdditionalLanguages` function. (`existingId` is the id of the language you want to add the extension to. You can find these id's in the [`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) file):
```javascript
registerAdditionalLanguage("id", [".fileExtension"], "existingId", monaco)
```
* If for instance you want to add more extensions to the php language set the id to `phpExt` and the existingId to `php`.
2. Copy the existing language definition into the `languageDefinitions` function in the same file. You can find the existing definitions in the following folder: [`/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/).
3. Execute the steps described in the [monaco_languages.json](#monaco_languagesjson) section.
### monaco_languages.json
[`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) contains all extensions and IDs for the languages supported by Monaco. The [`MonacoHelper`](/src/common/FilePreviewCommon/MonacoHelper.cs) class and the installer are using this file to register preview handlers for the defined extensions.
After updating Monaco Editor and/or adding a new language you should update the [`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) file.
1. Run the [`generateLanguagesJson.html`](/src/common/FilePreviewCommon/Assets/Monaco/generateLanguagesJson.html) file on a local webserver (as webbrowsers will block certain needed features when running the file locally.)
* This can for example be achieved by using the [Preview Server](https://marketplace.visualstudio.com/items?itemName=yuichinukiyama.vscode-preview-server) extension for Visual Studio Code: Open the file in Visual Studio Code, right click in the code editor and select `vscode-preview-server: Launch on browser`. The file will be opened in a browser.
2. The browser will download the new `monaco_languages.json` file
3. Replace the old file with the newly downloaded one in the source code folder.

View File

@@ -1,5 +1,7 @@
# Classes and structures
> This document is outdated and will soon be renewed.
#### class Animation: [header](/src/common/animation.h) [source](/src/common/animation.cpp)
Animation helper class with two easing-in animations: linear and exponential.

View File

@@ -0,0 +1,7 @@
# Common
The [common](/src/common) folder contains projects with code, that is used in multiple projects.
## [FilePreviewCommon](FilePreviewCommon.md)
This project contains common code for file previewing.

View File

@@ -3,6 +3,7 @@
- [ ] Microsoft plugin project name pattern: `Microsoft.PowerToys.Run.Plugin.{PluginName}`
- [ ] Community plugin project name pattern: `Community.PowerToys.Run.Plugin.{PluginName}`
- [ ] The project file should import `Version.props` and specify `<Version>$(Version).0</Version>`
- [ ] If the plugin uses any 3rd party dependencies the project file should import `DynamicPlugin.props`
- [ ] Make sure `*.csproj` specify only x64 platform target
- [ ] The plugin has to contain a `plugin.json` file of the following format in its root folder
```
@@ -17,7 +18,8 @@
"Website": "https://aka.ms/powertoys",
"ExecuteFileName": string, // Should be {Type}.PowerToys.Run.Plugin.{PluginName}.dll
"IcoPathDark": string, // Path to dark theme icon. The path is relative to the root plugin folder
"IcoPathLight": string // Path to light theme icon. The path is relative to the root plugin folder
"IcoPathLight": string // Path to light theme icon. The path is relative to the root plugin folder
"DynamicLoading": bool // Sets whether the plugin should dynamically load any dependencies isolated from the core application.
}
```
- [ ] Make sure your `Main` class contains a public, static string property for the `PluginID`. The plugin id has to be the same as the one in the `plugin.json`file.

View File

@@ -0,0 +1,7 @@
# PowerToys Peek
> Documentation is currently under construction
## Dev file previewer
The previewer for developer files uses the project in [FileExplorerCommon] common project to render monaco. You can find its documentation here: [/doc/devdocs/common/FilePreviewCommon.md](/doc/devdocs/common/FilePreviewCommon.md).

View File

@@ -1,24 +0,0 @@
# Developer Preview (Monaco)
Developer preview is based on [Microsoft's Monaco Editor](https://microsoft.github.io/monaco-editor/) which is maintained by the Visual Studio Code team.
## Update monaco editor
1. Download Monaco editor with npm: `npm i monaco-editor`.
2. Delete everything except the `min` folder (the minimised code).
3. Copy the `min` folder inside the [`monacoSRC`](/src/modules/previewpane/MonacoPreviewHandler/monacoSRC) folder.
4. Generate the JSON file (see section below)
## monaco_languages.json
[`monaco_languages.json`](/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json) contains all extensions and Id's for the supported languages of Monaco. The [`FileHandler`](/src/modules/previewpane/MonacoPreviewHandler/FileHandler.cs) class and the installer are using this file.
### Generate monaco_languages.json file
After you updated monaco editor or adding a new language you should update the [`monaco_languages.json`](/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json) file.
You have to run the file on a local webserver!
1. Build monaco in debug mode.
2. Open [generateLanguagesJson.html](/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html) in a browser.
3. Replace the old JSON file.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -33,3 +33,4 @@ Contact the developers of a plugin directly for assistance with a specific plugi
| [Quick Lookup](https://github.com/GTGalaxi/quick-lookup-ptrun) | [gtgalaxi](https://github.com/GTGalaxi) | Search across multiple cyber security tools |
| [Visual Studio](https://github.com/davidegiacometti/PowerToys-Run-VisualStudio) | [davidegiacometti](https://github.com/davidegiacometti) | Open Visual Studio recents |
| [WinGet](https://github.com/bostrot/PowerToysRunPluginWinget) | [bostrot](https://github.com/bostrot) | Search and install packages from WinGet |
| [Scoop](https://github.com/Quriz/PowerToysRunScoop) | [Quriz](https://github.com/Quriz) | Search and install packages from Scoop |

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?include $(sys.CURRENTDIR)\Common.wxi?>
<Fragment>
<DirectoryRef Id="INSTALLFOLDER" FileSource="$(var.BinDir)">
<!-- !Warning! Make sure to change Component Guid if you update the file list -->
<Component Id="Module_CmdNotFound" Win64="yes" Guid="80F648F2-29F6-4685-AED4-04DC1B6EE176">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdNotFound" Value="" KeyPath="yes"/>
</RegistryKey>
<File Source="$(var.BinDir)WinGetCommandNotFound.psd1" />
<!-- The dll files will be picked up by BaseApplications generateAllFileComponents.ps1-->
</Component>
</DirectoryRef>
<ComponentGroup Id="CmdNotFoundComponentGroup">
<ComponentRef Id="Module_CmdNotFound" />
</ComponentGroup>
</Fragment>
</Wix>

View File

@@ -18,6 +18,7 @@
<?define PastePlainProjectName="PastePlain"?>
<?define RegistryPreviewProjectName="RegistryPreview"?>
<?define PeekProjectName="Peek"?>
<?define CmdNotFoundProjectName="CmdNotFound"?>
<?define RepoDir="$(var.ProjectDir)..\..\" ?>
<?if $(var.Platform) = x64?>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureNuGetPackageBuildImports" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureNuGetPackageBuildImports"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\wix.props" Condition="Exists('..\wix.props')" />
<Import Project="..\..\src\Version.props" />
<PropertyGroup Condition="'$(Platform)' == 'x64'">
@@ -14,7 +15,7 @@ SET PTRoot=$(SolutionDir)\..
call "..\..\..\publish.cmd" x64
)
call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuildThisFileDirectory)\generateMonacoWxs.ps1 -monacoWxsFile "$(MSBuildThisFileDirectory)\MonacoSRC.wxs"
</PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' != 'x64'">
@@ -25,7 +26,7 @@ SET PTRoot=$(SolutionDir)\..
call "..\..\..\publish.cmd" arm64
)
call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuildThisFileDirectory)\generateMonacoWxs.ps1 -monacoWxsFile "$(MSBuildThisFileDirectory)\MonacoSRC.wxs"
</PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
@@ -67,7 +68,7 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
<PropertyGroup>
<!-- We do not support debug installer builds -->
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform>$(Platform)</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>022a9d30-7c4f-416d-a9df-5ff2661cc0ad</ProjectGuid>
@@ -103,6 +104,7 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
<Compile Include="Awake.wxs" />
<Compile Include="BaseApplications.wxs" />
<Compile Include="CmdNotFound.wxs" />
<Compile Include="ColorPicker.wxs" />
<Compile Include="EnvironmentVariables.wxs" />
<Compile Include="FileExplorerPreview.wxs" />
@@ -180,17 +182,6 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil
<Target Name="AfterBuild">
</Target> -->
<Target Name="BeforeBuild">
<HeatDirectory Directory="..\..\src\common\FilePreviewCommon\Assets\Monaco\monacoSRC"
PreprocessorVariable="var.MonacoSRCHarvestPath"
OutputFile="MonacoSRC.wxs"
ComponentGroupName="MonacoSRCHeatGenerated"
DirectoryRefId="MonacoPreviewHandlerMonacoSRCFolder"
AutogenerateGuids="false"
GenerateGuidsNow="true"
ToolPath="$(WixToolPath)"
RunAsSeparateProcess="true"
SuppressFragments="false"
SuppressRegistry="false"
SuppressRootDirectory="true"/>
<HeatDirectory Directory="..\..\src\common\FilePreviewCommon\Assets\Monaco\monacoSRC" PreprocessorVariable="var.MonacoSRCHarvestPath" OutputFile="MonacoSRC.wxs" ComponentGroupName="MonacoSRCHeatGenerated" DirectoryRefId="MonacoPreviewHandlerMonacoSRCFolder" AutogenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" RunAsSeparateProcess="true" SuppressFragments="false" SuppressRegistry="false" SuppressRootDirectory="true"/>
</Target>
</Project>

View File

@@ -72,6 +72,7 @@
<ComponentGroupRef Id="VideoConferenceComponentGroup" />
<ComponentGroupRef Id="MouseWithoutBordersComponentGroup" />
<ComponentGroupRef Id="EnvironmentVariablesComponentGroup" />
<ComponentGroupRef Id="CmdNotFoundComponentGroup" />
<ComponentGroupRef Id="ResourcesComponentGroup" />
<ComponentGroupRef Id="WindowsAppSDKComponentGroup" />
@@ -133,6 +134,7 @@
<InstallExecuteSequence>
<Custom Action="DetectPrevInstallPath" After="AppSearch" />
<Custom Action="SetLaunchPowerToysParam" Before="LaunchPowerToys" />
<Custom Action="SetUninstallCommandNotFoundParam" Before="UninstallCommandNotFound" />
<Custom Action="SetApplyModulesRegistryChangeSetsParam" Before="ApplyModulesRegistryChangeSets" />
<Custom Action="SetUnApplyModulesRegistryChangeSetsParam" Before="UnApplyModulesRegistryChangeSets" />
<Custom Action="CheckGPO" After="InstallInitialize">
@@ -159,6 +161,9 @@
<Custom Action="UnRegisterContextMenuPackages" Before="RemoveFiles">
Installed AND (REMOVE="ALL")
</Custom>
<Custom Action="UninstallCommandNotFound" Before="RemoveFiles">
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
<Custom Action="UninstallServicesTask" After="InstallFinalize">
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
@@ -200,6 +205,10 @@
Property="UnApplyModulesRegistryChangeSets"
Value="[INSTALLFOLDER]" />
<CustomAction Id="SetUninstallCommandNotFoundParam"
Property="UninstallCommandNotFound"
Value="[INSTALLFOLDER]" />
<CustomAction Id="SetCreateWinAppSDKHardlinksParam"
Property="CreateWinAppSDKHardlinks"
Value="[INSTALLFOLDER]" />
@@ -252,7 +261,15 @@
BinaryKey="PTCustomActions"
DllEntry="UninstallServicesCA"
/>
<CustomAction Id="UninstallCommandNotFound"
Return="ignore"
Impersonate="yes"
Execute="deferred"
BinaryKey="PTCustomActions"
DllEntry="UninstallCommandNotFoundModuleCA"
/>
<CustomAction Id="TelemetryLogInstallSuccess"
Return="ignore"
Impersonate="yes"

View File

@@ -19,12 +19,14 @@
<Fragment>
<DirectoryRef Id="WinUI3AppsAssetsFolder">
<Directory Id="SettingsV2AssetsInstallFolder" Name="Settings">
<Directory Id="SettingsAppAssetsScriptsFolder" Name="Scripts"/>
<Directory Id="SettingsV2OOBEAssetsFluentIconsInstallFolder" Name="FluentIcons" />
<Directory Id="SettingsV2AssetsModulesInstallFolder" Name="Modules" >
<Directory Id="SettingsV2OOBEAssetsModulesInstallFolder" Name="OOBE" />
</Directory>
</Directory>
</DirectoryRef>
<DirectoryRef Id="SettingsV2AssetsInstallFolder" FileSource="$(var.SettingsV2AssetsFilesPath)">
<!-- Generated by generateFileComponents.ps1 -->
<!--SettingsV2AssetsFiles_Component_Def-->
@@ -45,6 +47,16 @@
<!--SettingsV2OOBEAssetsFluentIconsFiles_Component_Def-->
</DirectoryRef>
<DirectoryRef Id="SettingsAppAssetsScriptsFolder" FileSource="$(var.SettingsV2AssetsFilesPath)\Scripts\">
<Component Id="CommandNotFound_Scripts" Win64="yes" Guid="898EFA1E-EDD3-4F4B-8C7F-4A14B0D05B02">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="CommandNotFound_Scripts" Value="" KeyPath="yes"/>
</RegistryKey>
<File Id="CommandNotFound_Scripts_EnableModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\EnableModule.ps1" />
<File Id="CommandNotFound_Scripts_DisableModule.ps1" Source="$(var.SettingsV2AssetsFilesPath)\Scripts\DisableModule.ps1" />
</Component>
</DirectoryRef>
<ComponentGroup Id="SettingsComponentGroup">
<Component Id="RemoveSettingsFolder" Guid="2D3AEF68-4E5A-4FF9-A5C0-9E53391AC754" Directory="SettingsV2AssetsInstallFolder" >
@@ -55,7 +67,9 @@
<RemoveFolder Id="RemoveFolderSettingsV2OOBEAssetsFluentIconsInstallFolder" Directory="SettingsV2OOBEAssetsFluentIconsInstallFolder" On="uninstall"/>
<RemoveFolder Id="RemoveFolderSettingsV2AssetsModulesInstallFolder" Directory="SettingsV2AssetsModulesInstallFolder" On="uninstall"/>
<RemoveFolder Id="RemoveFolderSettingsV2OOBEAssetsModulesInstallFolder" Directory="SettingsV2OOBEAssetsModulesInstallFolder" On="uninstall"/>
<RemoveFolder Id="RemoveFolderSettingsAppAssetsScriptsFolder" Directory="SettingsAppAssetsScriptsFolder" On="uninstall"/>
</Component>
<ComponentRef Id="CommandNotFound_Scripts"/>
</ComponentGroup>
</Fragment>

View File

@@ -433,7 +433,29 @@ UINT __stdcall RemoveWindowsServiceByName(std::wstring serviceName)
return ERROR_SUCCESS;
}
UINT __stdcall UninstallCommandNotFoundModuleCA(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
std::wstring installationFolder;
std::string command;
hr = WcaInitialize(hInstall, "UninstallCommandNotFoundModule");
ExitOnFailure(hr, "Failed to initialize");
hr = getInstallFolder(hInstall, installationFolder);
ExitOnFailure(hr, "Failed to get installFolder.");
command = "pwsh.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(installationFolder) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "\"";
system(command.c_str());
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
UINT __stdcall UninstallServicesCA(MSIHANDLE hInstall)
{

View File

@@ -22,4 +22,5 @@ EXPORTS
UninstallVirtualCameraDriverCA
UnRegisterContextMenuPackagesCA
UninstallEmbeddedMSIXCA
UninstallServicesCA
UninstallServicesCA
UninstallCommandNotFoundModuleCA

View File

@@ -96,49 +96,4 @@ end_of_line = crlf
dotnet_diagnostic.IDE0065.severity = none
# IDE0009: Add this or Me qualification
dotnet_diagnostic.IDE0009.severity = none
# CA1859: Change type for improved performance
dotnet_diagnostic.CA1859.severity = none
# CA1716: Identifiers should not match keywords
dotnet_diagnostic.CA1716.severity = none
# SYSLIB1096: Convert to 'GeneratedComInterface'
dotnet_diagnostic.SYSLIB1096.severity = silent
# CA1309: Use ordinal StringComparison
dotnet_diagnostic.CA1309.severity = suggestion
# CS1615: Argument may not be passed with the ref keyword
dotnet_diagnostic.CS1615.severity = none
# CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup
dotnet_diagnostic.CA1854.severity = suggestion
# CA1860: Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1860.severity = suggestion
# CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
dotnet_diagnostic.CA1861.severity = suggestion
# CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons
dotnet_diagnostic.CA1862.severity = suggestion
# CA1863: Cache a CompositeFormat for repeated use in this formatting operation
dotnet_diagnostic.CA1863.severity = none
# CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
dotnet_diagnostic.CA1864.severity = suggestion
# CA1865: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
dotnet_diagnostic.CA1865.severity = suggestion
# CA1869: Cache and reuse 'JsonSerializerOptions' instances
dotnet_diagnostic.CA1869.severity = none
# CA2208: Instantiate argument exceptions correctly
dotnet_diagnostic.CA2208.severity = none
# CS9191: The 'ref' modifier for argument corresponding to 'in' is equivalent to 'in'. Consider using 'in' instead.
dotnet_diagnostic.CS9191.severity = none
dotnet_diagnostic.IDE0009.severity = none

View File

@@ -145,7 +145,7 @@ namespace AllExperiments
private string? AssignmentUnit { get; set; }
private IVariantAssignmentRequest GetVariantAssignmentRequest()
private VariantAssignmentRequest GetVariantAssignmentRequest()
{
var jsonFilePath = CreateFilePath();
try

View File

@@ -4,12 +4,15 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<Version>$(Version).0</Version>
<Authors>Microsoft Corporation</Authors>
<Product>PowerToys</Product>
<Description>PowerToys FilePreviewCommon</Description>
<AssemblyName>PowerToys.FilePreviewCommon</AssemblyName>
<UseWindowsForms>true</UseWindowsForms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@@ -32,7 +35,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Assets\Monaco\monacoSRC\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Update="Assets\Monaco\monaco_languages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -12,6 +12,12 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters
/// <inheritdoc/>
public string LangSet => "json";
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
};
/// <inheritdoc/>
public string Format(string value)
{
@@ -22,11 +28,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters
using (var jDocument = JsonDocument.Parse(value, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }))
{
return JsonSerializer.Serialize(jDocument, new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
});
return JsonSerializer.Serialize(jDocument, _serializerOptions);
}
}
}

View File

@@ -26,7 +26,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters
var stringBuilder = new StringBuilder();
var xmlWriterSettings = new XmlWriterSettings()
{
OmitXmlDeclaration = xmlDocument.FirstChild.NodeType != XmlNodeType.XmlDeclaration,
OmitXmlDeclaration = xmlDocument.FirstChild?.NodeType != XmlNodeType.XmlDeclaration,
Indent = true,
};

View File

@@ -8,7 +8,7 @@ using System.IO;
using System.Linq;
using System.Text;
namespace Common.Utilities
namespace Microsoft.PowerToys.FilePreviewCommon
{
/// <summary>
/// Gcode file helper class.

View File

@@ -5,9 +5,8 @@
using System;
using System.Drawing;
using System.IO;
using PreviewHandlerCommon.Utilities;
namespace Common.Utilities
namespace Microsoft.PowerToys.FilePreviewCommon
{
/// <summary>
/// Represents a gcode thumbnail.

View File

@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Common.Utilities
namespace Microsoft.PowerToys.FilePreviewCommon
{
/// <summary>
/// The gcode thumbnail image format.

View File

@@ -30,7 +30,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon
// Extension to modify markdown AST.
HTMLParsingExtension extension = new HTMLParsingExtension(imagesBlockedCallBack);
extension.FilePath = Path.GetDirectoryName(filePath);
extension.FilePath = Path.GetDirectoryName(filePath) ?? string.Empty;
// if you have a string with double space, some people view it as a new line.
// while this is against spec, even GH supports this. Technically looks like GH just trims whitespace

View File

@@ -28,12 +28,12 @@ namespace Microsoft.PowerToys.FilePreviewCommon
new XmlFormatter(),
}.AsReadOnly();
private static string _monacoDirectory;
private static string? _monacoDirectory;
public static string GetRuntimeMonacoDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().Location;
string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase), "Assets", "Monaco"));
string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "Assets", "Monaco"));
if (Path.Exists(path))
{
return path;
@@ -41,7 +41,7 @@ namespace Microsoft.PowerToys.FilePreviewCommon
else
{
// We're likely in WinUI3Apps directory and need to go back to the base directory.
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase), "..", "Assets", "Monaco"));
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "..", "Assets", "Monaco"));
}
}

View File

@@ -0,0 +1,177 @@
// 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;
using System.Buffers.Binary;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
//// Based on https://github.com/phoboslab/qoi/blob/master/qoi.h
namespace Microsoft.PowerToys.FilePreviewCommon
{
/// <summary>
/// QOI Image helper.
/// </summary>
public static class QoiImage
{
#pragma warning disable SA1310 // Field names should not contain underscore
private const byte QOI_OP_INDEX = 0x00; // 00xxxxxx
private const byte QOI_OP_DIFF = 0x40; // 01xxxxxx
private const byte QOI_OP_LUMA = 0x80; // 10xxxxxx
private const byte QOI_OP_RUN = 0xc0; // 11xxxxxx
private const byte QOI_OP_RGB = 0xfe; // 11111110
private const byte QOI_OP_RGBA = 0xff; // 11111111
private const byte QOI_MASK_2 = 0xc0; // 11000000
private const int QOI_MAGIC = 'q' << 24 | 'o' << 16 | 'i' << 8 | 'f';
private const int QOI_HEADER_SIZE = 14;
private const uint QOI_PIXELS_MAX = 400000000;
private const byte QOI_PADDING_LENGTH = 8;
#pragma warning restore SA1310 // Field names should not contain underscore
private record struct QoiPixel(byte R, byte G, byte B, byte A)
{
public readonly int GetColorHash() => (R * 3) + (G * 5) + (B * 7) + (A * 11);
}
/// <summary>
/// Creates a <see cref="Bitmap"/> from the specified QOI data stream.
/// </summary>
/// <param name="stream">A <see cref="Stream"/> that contains the QOI data.</param>
/// <returns>The <see cref="Bitmap"/> this method creates.</returns>
/// <exception cref="ArgumentException">The stream does not have a valid QOI image format.</exception>
public static Bitmap FromStream(Stream stream)
{
var fileSize = stream.Length;
if (fileSize < QOI_HEADER_SIZE + QOI_PADDING_LENGTH)
{
throw new ArgumentException("Not enough data for a QOI file");
}
Bitmap? bitmap = null;
try
{
using var reader = new BinaryReader(stream, Encoding.UTF8, true);
var headerMagic = ReadUInt32BigEndian(reader);
if (headerMagic != QOI_MAGIC)
{
throw new ArgumentException("Invalid QOI file header");
}
var width = ReadUInt32BigEndian(reader);
var height = ReadUInt32BigEndian(reader);
var channels = reader.ReadByte();
var colorSpace = reader.ReadByte();
if (width == 0 || height == 0 || channels < 3 || channels > 4 || colorSpace > 1 || height >= QOI_PIXELS_MAX / width)
{
throw new ArgumentException("Invalid QOI file data");
}
var pixelFormat = channels == 4 ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb;
bitmap = new Bitmap((int)width, (int)height, pixelFormat);
var bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, pixelFormat);
var dataLength = bitmapData.Height * bitmapData.Stride;
var index = new QoiPixel[64];
var pixel = new QoiPixel(0, 0, 0, 255);
var run = 0;
var chunksLen = fileSize - QOI_PADDING_LENGTH;
for (var dataIndex = 0; dataIndex < dataLength; dataIndex += channels)
{
if (run > 0)
{
run--;
}
else if (stream.Position < chunksLen)
{
var b1 = reader.ReadByte();
if (b1 == QOI_OP_RGB)
{
pixel.R = reader.ReadByte();
pixel.G = reader.ReadByte();
pixel.B = reader.ReadByte();
}
else if (b1 == QOI_OP_RGBA)
{
pixel.R = reader.ReadByte();
pixel.G = reader.ReadByte();
pixel.B = reader.ReadByte();
pixel.A = reader.ReadByte();
}
else if ((b1 & QOI_MASK_2) == QOI_OP_INDEX)
{
pixel = index[b1];
}
else if ((b1 & QOI_MASK_2) == QOI_OP_DIFF)
{
pixel.R += (byte)(((b1 >> 4) & 0x03) - 2);
pixel.G += (byte)(((b1 >> 2) & 0x03) - 2);
pixel.B += (byte)((b1 & 0x03) - 2);
}
else if ((b1 & QOI_MASK_2) == QOI_OP_LUMA)
{
var b2 = reader.ReadByte();
var vg = (b1 & 0x3f) - 32;
pixel.R += (byte)(vg - 8 + ((b2 >> 4) & 0x0f));
pixel.G += (byte)vg;
pixel.B += (byte)(vg - 8 + (b2 & 0x0f));
}
else if ((b1 & QOI_MASK_2) == QOI_OP_RUN)
{
run = b1 & 0x3f;
}
index[pixel.GetColorHash() % 64] = pixel;
}
unsafe
{
var bitmapPixel = (byte*)bitmapData.Scan0 + dataIndex;
bitmapPixel[0] = pixel.B;
bitmapPixel[1] = pixel.G;
bitmapPixel[2] = pixel.R;
if (channels == 4)
{
bitmapPixel[3] = pixel.A;
}
}
}
bitmap.UnlockBits(bitmapData);
return bitmap;
}
catch
{
bitmap?.Dispose();
throw;
}
}
private static uint ReadUInt32BigEndian(BinaryReader reader)
{
var buffer = reader.ReadBytes(4);
return BinaryPrimitives.ReadUInt32BigEndian(buffer);
}
}
}

View File

@@ -12,6 +12,10 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredAwakeEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredCmdNotFoundEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredCmdNotFoundEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredColorPickerEnabledValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredColorPickerEnabledValue());

View File

@@ -9,6 +9,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
GPOWrapper() = default;
static GpoRuleConfigured GetConfiguredAlwaysOnTopEnabledValue();
static GpoRuleConfigured GetConfiguredAwakeEnabledValue();
static GpoRuleConfigured GetConfiguredCmdNotFoundEnabledValue();
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
static GpoRuleConfigured GetConfiguredCropAndLockEnabledValue();
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();

View File

@@ -13,6 +13,7 @@ namespace PowerToys
[default_interface] static runtimeclass GPOWrapper {
static GpoRuleConfigured GetConfiguredAlwaysOnTopEnabledValue();
static GpoRuleConfigured GetConfiguredAwakeEnabledValue();
static GpoRuleConfigured GetConfiguredCmdNotFoundEnabledValue();
static GpoRuleConfigured GetConfiguredColorPickerEnabledValue();
static GpoRuleConfigured GetConfiguredCropAndLockEnabledValue();
static GpoRuleConfigured GetConfiguredFancyZonesEnabledValue();

View File

@@ -27,6 +27,11 @@ namespace PowerToys.GPOWrapperProjection
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredFancyZonesEnabledValue();
}
public static GpoRuleConfigured GetConfiguredCmdNotFoundEnabledValue()
{
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredCmdNotFoundEnabledValue();
}
public static GpoRuleConfigured GetConfiguredColorPickerEnabledValue()
{
return (GpoRuleConfigured)PowerToys.GPOWrapper.GPOWrapper.GetConfiguredColorPickerEnabledValue();

View File

@@ -4,7 +4,7 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<Version>$(Version).0</Version>
<Authors>Microsoft Corporation</Authors>
<Product>PowerToys</Product>

View File

@@ -9,6 +9,7 @@ namespace ManagedCommon
AlwaysOnTop,
Awake,
ColorPicker,
CmdNotFound,
CropAndLock,
EnvironmentVariables,
FancyZones,

View File

@@ -67,6 +67,8 @@ struct LogSettings
inline const static std::string cropAndLockLoggerName = "crop-and-lock";
inline const static std::wstring registryPreviewLogPath = L"Logs\\registryPreview-log.txt";
inline const static std::string environmentVariablesLoggerName = "environment-variables";
inline const static std::wstring cmdNotFoundLogPath = L"Logs\\cmd-not-found-log.txt";
inline const static std::string cmdNotFoundLoggerName = "cmd-not-found";
inline const static int retention = 30;
std::wstring logLevel;
LogSettings();

View File

@@ -0,0 +1,36 @@
#pragma once
#include <common/notifications/notifications.h>
#include <common/notifications/dont_show_again.h>
#include <common/utils/resources.h>
#include "Generated Files/resource.h"
namespace notifications
{
// Non-Localizable strings
namespace NonLocalizable
{
const wchar_t RunAsAdminInfoPage[] = L"https://aka.ms/powertoysDetectedElevatedHelp";
const wchar_t ToastNotificationButtonUrl[] = L"powertoys://cant_drag_elevated_disable/";
}
inline void WarnIfElevationIsRequired(std::wstring title, std::wstring message, std::wstring button1, std::wstring button2)
{
using namespace NonLocalizable;
static bool warning_shown = false;
if (!warning_shown && !is_toast_disabled(ElevatedDontShowAgainRegistryPath, ElevatedDisableIntervalInDays))
{
std::vector<action_t> actions = {
link_button{ button1, RunAsAdminInfoPage },
link_button{ button2, ToastNotificationButtonUrl }
};
show_toast_with_activations(message,
title,
{},
std::move(actions));
warning_shown = true;
}
}
}

View File

@@ -4,8 +4,8 @@
namespace notifications
{
const inline wchar_t CantDragElevatedDontShowAgainRegistryPath[] = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\{e16ea82f-6d94-4f30-bb02-d6d911588afd})";
const inline int64_t CantDragElevatedDisableIntervalInDays = 30;
const inline wchar_t ElevatedDontShowAgainRegistryPath[] = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\{e16ea82f-6d94-4f30-bb02-d6d911588afd})";
const inline int64_t ElevatedDisableIntervalInDays = 30;
const inline wchar_t PreviewModulesDontShowAgainRegistryPath[] = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\{7e29e2b2-b31c-4dcd-b7b0-79c078b02430})";
const inline int64_t PreviewModulesDisableIntervalInDays = 30;

View File

@@ -27,6 +27,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="notifications.h" />
<ClInclude Include="NotificationUtil.h" />
<ClInclude Include="dont_show_again.h" />
<ClInclude Include="pch.h" />
</ItemGroup>

View File

@@ -494,3 +494,30 @@ inline bool check_user_is_admin()
freeMemory(pSID, pGroupInfo);
return false;
}
inline bool IsProcessOfWindowElevated(HWND window)
{
DWORD pid = 0;
GetWindowThreadProcessId(window, &pid);
if (!pid)
{
return false;
}
wil::unique_handle hProcess{ OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION,
FALSE,
pid) };
wil::unique_handle token;
if (OpenProcessToken(hProcess.get(), TOKEN_QUERY, &token))
{
TOKEN_ELEVATION elevation;
DWORD size;
if (GetTokenInformation(token.get(), TokenElevation, &elevation, sizeof(elevation), &size))
{
return elevation.TokenIsElevated != 0;
}
}
return false;
}

View File

@@ -32,7 +32,7 @@ inline bool find_folder_in_path(const std::wstring& where, const std::vector<std
}
#define MAX_TITLE_LENGTH 255
inline bool check_excluded_app_with_title(const HWND& hwnd, std::wstring& processPath, const std::vector<std::wstring>& excludedApps)
inline bool check_excluded_app_with_title(const HWND& hwnd, const std::vector<std::wstring>& excludedApps)
{
WCHAR title[MAX_TITLE_LENGTH];
int len = GetWindowTextW(hwnd, title, MAX_TITLE_LENGTH);
@@ -42,23 +42,25 @@ inline bool check_excluded_app_with_title(const HWND& hwnd, std::wstring& proces
}
std::wstring titleStr(title);
auto lastBackslashPos = processPath.find_last_of(L'\\');
if (lastBackslashPos != std::wstring::npos)
CharUpperBuffW(titleStr.data(), static_cast<DWORD>(titleStr.length()));
for (const auto& app : excludedApps)
{
processPath = processPath.substr(0, lastBackslashPos + 1); // retain up to the last backslash
processPath.append(titleStr); // append the title
if (titleStr.contains(app))
{
return true;
}
}
CharUpperBuffW(processPath.data(), static_cast<DWORD>(processPath.length()));
return find_app_name_in_path(processPath, excludedApps);
return false;
}
inline bool check_excluded_app(const HWND& hwnd, std::wstring& processPath, const std::vector<std::wstring>& excludedApps)
inline bool check_excluded_app(const HWND& hwnd, const std::wstring& processPath, const std::vector<std::wstring>& excludedApps)
{
bool res = find_app_name_in_path(processPath, excludedApps);
if (!res)
{
res = check_excluded_app_with_title(hwnd, processPath, excludedApps);
res = check_excluded_app_with_title(hwnd, excludedApps);
}
return res;

View File

@@ -24,6 +24,7 @@ namespace powertoys_gpo {
const std::wstring POLICY_CONFIGURE_ENABLED_GLOBAL_ALL_UTILITIES = L"ConfigureGlobalUtilityEnabledState";
const std::wstring POLICY_CONFIGURE_ENABLED_ALWAYS_ON_TOP = L"ConfigureEnabledUtilityAlwaysOnTop";
const std::wstring POLICY_CONFIGURE_ENABLED_AWAKE = L"ConfigureEnabledUtilityAwake";
const std::wstring POLICY_CONFIGURE_ENABLED_CMD_NOT_FOUND = L"ConfigureEnabledUtilityCmdNotFound";
const std::wstring POLICY_CONFIGURE_ENABLED_COLOR_PICKER = L"ConfigureEnabledUtilityColorPicker";
const std::wstring POLICY_CONFIGURE_ENABLED_CROP_AND_LOCK = L"ConfigureEnabledUtilityCropAndLock";
const std::wstring POLICY_CONFIGURE_ENABLED_FANCYZONES = L"ConfigureEnabledUtilityFancyZones";
@@ -224,6 +225,11 @@ namespace powertoys_gpo {
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_AWAKE);
}
inline gpo_rule_configured_t getConfiguredCmdNotFoundEnabledValue()
{
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_CMD_NOT_FOUND);
}
inline gpo_rule_configured_t getConfiguredColorPickerEnabledValue()
{
return getUtilityEnabledValue(POLICY_CONFIGURE_ENABLED_COLOR_PICKER);

View File

@@ -15,6 +15,7 @@
<definition name="SUPPORTED_POWERTOYS_0_73_0" displayName="$(string.SUPPORTED_POWERTOYS_0_73_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_75_0" displayName="$(string.SUPPORTED_POWERTOYS_0_75_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_76_0" displayName="$(string.SUPPORTED_POWERTOYS_0_76_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_77_0" displayName="$(string.SUPPORTED_POWERTOYS_0_77_0)"/>
</definitions>
</supportedOn>
<categories>
@@ -59,6 +60,16 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityCmdNotFound" class="Both" displayName="$(string.ConfigureEnabledUtilityCmdNotFound)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityCmdNotFound">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_77_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="ConfigureEnabledUtilityColorPicker" class="Both" displayName="$(string.ConfigureEnabledUtilityColorPicker)" explainText="$(string.ConfigureEnabledUtilityDescription)" key="Software\Policies\PowerToys" valueName="ConfigureEnabledUtilityColorPicker">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_64_0" />

View File

@@ -17,6 +17,7 @@
<string id="SUPPORTED_POWERTOYS_0_73_0">PowerToys version 0.73.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_75_0">PowerToys version 0.75.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_76_0">PowerToys version 0.76.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_77_0">PowerToys version 0.77.0 or later</string>
<string id="ConfigureGlobalUtilityEnabledStateDescription">This policy configures the enabled state for all PowerToys utilities.
@@ -112,6 +113,7 @@ Note: Changes require a restart of PowerToys Run.
<string id="ConfigureEnabledUtilityAlwaysOnTop">Always On Top: Configure enabled state</string>
<string id="ConfigureEnabledUtilityAwake">Awake: Configure enabled state</string>
<string id="ConfigureEnabledUtilityColorPicker">Color Picker: Configure enabled state</string>
<string id="ConfigureEnabledUtilityCmdNotFound">Command Not Found: Configure enabled state</string>
<string id="ConfigureEnabledUtilityCropAndLock">Crop And Lock: Configure enabled state</string>
<string id="ConfigureEnabledUtilityEnvironmentVariables">Environment Variables: Configure enabled state</string>
<string id="ConfigureEnabledUtilityFancyZones">FancyZones: Configure enabled state</string>

View File

@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using EnvironmentVariables.Helpers;
using EnvironmentVariables.Helpers.Win32;
using EnvironmentVariables.ViewModels;
using ManagedCommon;
using Microsoft.UI.Dispatching;
using WinUIEx;
@@ -30,19 +31,20 @@ namespace EnvironmentVariables
Title = title;
AppTitleTextBlock.Text = title;
RegisterWindow();
var handle = this.GetWindowHandle();
RegisterWindow(handle);
WindowHelpers.BringToForeground(handle);
}
private static readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
private static NativeMethods.WinProc newWndProc;
private static IntPtr oldWndProc = IntPtr.Zero;
private void RegisterWindow()
private void RegisterWindow(IntPtr handle)
{
newWndProc = new NativeMethods.WinProc(WndProc);
var handle = this.GetWindowHandle();
oldWndProc = NativeMethods.SetWindowLongPtr(handle, NativeMethods.WindowLongIndexFlags.GWL_WNDPROC, newWndProc);
}

View File

@@ -17,7 +17,7 @@ namespace Hosts.Settings
private const string HostsModuleName = "Hosts";
private const int MaxNumberOfRetry = 5;
private readonly ISettingsUtils _settingsUtils;
private readonly SettingsUtils _settingsUtils;
private readonly IFileSystemWatcher _watcher;
private readonly object _loadingSettingsLock = new object();

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props')" />
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.props')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
@@ -146,8 +146,8 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@@ -156,9 +156,9 @@
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220914.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.755\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.WindowsAppSDK.1.4.231115000\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
</Target>
</Project>

View File

@@ -2,6 +2,6 @@
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.221104.6" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.755" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.756" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.4.231115000" targetFramework="native" />
</packages>

View File

@@ -45,6 +45,10 @@ namespace MouseWithoutBorders
private static string lastDragDropFile;
private static long clipboardCopiedTime;
internal static readonly char[] Comma = new char[] { ',' };
internal static readonly char[] Star = new char[] { '*' };
internal static readonly char[] NullSeparator = new char[] { '\0' };
internal static ID LastIDWithClipboardData { get; set; }
internal static string LastDragDropFile
@@ -406,7 +410,7 @@ namespace MouseWithoutBorders
try
{
remoteMachine = postAct.Contains("mspaint,") ? postAct.Split(new char[] { ',' })[1] : Common.LastMachineWithClipboardData;
remoteMachine = postAct.Contains("mspaint,") ? postAct.Split(Comma)[1] : Common.LastMachineWithClipboardData;
remoteMachine = remoteMachine.Trim();
@@ -518,7 +522,7 @@ namespace MouseWithoutBorders
fileName = Common.GetStringU(header).Replace("\0", string.Empty);
Common.LogDebug("Header: " + fileName);
string[] headers = fileName.Split(new char[] { '*' });
string[] headers = fileName.Split(Star);
if (headers.Length < 2 || !long.TryParse(headers[0], out long dataSize))
{
@@ -973,7 +977,7 @@ namespace MouseWithoutBorders
foreach (string txt in texts)
{
if (string.IsNullOrEmpty(txt.Trim(new char[] { '\0' })))
if (string.IsNullOrEmpty(txt.Trim(NullSeparator)))
{
continue;
}

View File

@@ -22,7 +22,9 @@ namespace MouseWithoutBorders
{
internal partial class Common
{
private static SymmetricAlgorithm symAl;
#pragma warning disable SYSLIB0021
private static AesCryptoServiceProvider symAl;
#pragma warning restore SYSLIB0021
private static string myKey;
private static uint magicNumber;
private static Random ran = new(); // Used for non encryption related functionality.

View File

@@ -313,7 +313,8 @@ namespace MouseWithoutBorders
HasSwitchedMachineSinceLastCopy = true;
// Common.CreateLowIntegrityProcess("\"" + Path.GetDirectoryName(Application.ExecutablePath) + "\\MouseWithoutBordersHelper.exe\"", string.Empty, 0, false, 0);
if (Process.GetProcessesByName(HelperProcessName)?.Any() != true)
var processes = Process.GetProcessesByName(HelperProcessName);
if (processes?.Length == 0)
{
Log("Unable to start helper process.");
Common.ShowToolTip("Error starting Mouse Without Borders Helper, clipboard sharing will not work!", 5000, ToolTipIcon.Error);
@@ -325,7 +326,8 @@ namespace MouseWithoutBorders
}
else
{
if (Process.GetProcessesByName(HelperProcessName)?.Any() == true)
var processes = Process.GetProcessesByName(HelperProcessName);
if (processes?.Length > 0)
{
Log("Helper process found running.");
}
@@ -432,7 +434,7 @@ namespace MouseWithoutBorders
{
if (string.IsNullOrEmpty(Setting.Values.Username) && !Common.RunOnLogonDesktop)
{
if (Program.User.ToLower(CultureInfo.CurrentCulture).Contains("system"))
if (Program.User.Contains("system", StringComparison.CurrentCultureIgnoreCase))
{
_ = Common.ImpersonateLoggedOnUserAndDoSomething(() =>
{

View File

@@ -84,12 +84,11 @@ namespace MouseWithoutBorders
}
}
[SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower", Justification = "Dotnet port with style preservation")]
internal static int CreateProcessInInputDesktopSession(string commandLine, string arg, string desktop, short wShowWindow, bool lowIntegrity = false)
// As user who runs explorer.exe
{
if (!Program.User.ToLower(CultureInfo.InvariantCulture).Contains("system"))
if (!Program.User.Contains("system", StringComparison.InvariantCultureIgnoreCase))
{
ProcessStartInfo s = new(commandLine, arg);
s.WindowStyle = wShowWindow != 0 ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;

View File

@@ -45,7 +45,7 @@ namespace MouseWithoutBorders
{
Process[] ps = Process.GetProcessesByName("MouseWithoutBordersSvc");
if (ps.Any())
if (ps.Length != 0)
{
if (DateTime.UtcNow - lastStartServiceTime < TimeSpan.FromSeconds(5))
{

View File

@@ -353,6 +353,7 @@ namespace MouseWithoutBorders.Class
private static bool ctrlDown;
private static bool altDown;
private static bool shiftDown;
internal static readonly string[] Args = new string[] { "CAD" };
private static void ResetModifiersState(HotkeySettings matchingHotkey)
{
@@ -456,7 +457,7 @@ namespace MouseWithoutBorders.Class
if (ctrlDown && altDown)
{
ctrlDown = altDown = false;
new ServiceController("MouseWithoutBordersSvc").Start(new string[] { "CAD" });
new ServiceController("MouseWithoutBordersSvc").Start(Args);
}
break;

View File

@@ -156,7 +156,7 @@ namespace MouseWithoutBorders.Class
}
else if (list.Count >= 4)
{
throw new ArgumentException("machineNames.Length > Common.MAX_MACHINE");
throw new ArgumentException($"The number of machines exceeded the maximum allowed limit of {Common.MAX_MACHINE}. Actual count: {list.Count}.");
}
_ = LearnMachine(name);
@@ -178,7 +178,7 @@ namespace MouseWithoutBorders.Class
}
else if (list.Count >= 4)
{
throw new ArgumentException("infos.Length > Common.MAX_MACHINE");
throw new ArgumentException($"The number of machines exceeded the maximum allowed limit of {Common.MAX_MACHINE}. Actual count: {list.Count}.");
}
_ = LearnMachine(inf.Name);

View File

@@ -8,6 +8,9 @@ namespace MouseWithoutBorders.Class
{
internal static class MachinePoolHelpers
{
internal static readonly char[] Comma = new char[] { ',' };
internal static readonly char[] Colon = new char[] { ':' };
internal static MachineInf[] LoadMachineInfoFromMachinePoolStringSetting(string s)
{
if (s == null)
@@ -15,7 +18,7 @@ namespace MouseWithoutBorders.Class
throw new ArgumentNullException(s);
}
string[] st = s.Split(new char[] { ',' });
string[] st = s.Split(Comma);
if (st.Length < Common.MAX_MACHINE)
{
@@ -25,7 +28,7 @@ namespace MouseWithoutBorders.Class
MachineInf[] rv = new MachineInf[Common.MAX_MACHINE];
for (int i = 0; i < Common.MAX_MACHINE; i++)
{
string[] mc = st[i].Split(new char[] { ':' });
string[] mc = st[i].Split(Colon);
if (mc.Length == 2)
{
rv[i].Name = mc[0];

View File

@@ -38,7 +38,7 @@ namespace MouseWithoutBorders.Class
{
internal bool Changed;
private readonly ISettingsUtils _settingsUtils;
private readonly SettingsUtils _settingsUtils;
private readonly object _loadingSettingsLock = new object();
private readonly IFileSystemWatcher _watcher;

View File

@@ -887,14 +887,14 @@ namespace MouseWithoutBorders.Class
if (!string.IsNullOrEmpty(Setting.Values.Name2IP))
{
string[] name2ip = Setting.Values.Name2IP.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
string[] name2ip = Setting.Values.Name2IP.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
string[] nameNip;
if (name2ip != null)
{
foreach (string st in name2ip)
{
nameNip = st.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
nameNip = st.Split(BlankSeparator, StringSplitOptions.RemoveEmptyEntries);
if (nameNip != null && nameNip.Length >= 2 && nameNip[0].Trim().Equals(machineName, StringComparison.OrdinalIgnoreCase)
&& IPAddress.TryParse(nameNip[1].Trim(), out IPAddress ip) && !validAddressesSt.Contains("[" + ip.ToString() + "]")
@@ -1063,7 +1063,7 @@ namespace MouseWithoutBorders.Class
List<IPAddress> localIPv4Addresses = GetMyIPv4Addresses().ToList();
if (!localIPv4Addresses.Any())
if (localIPv4Addresses.Count == 0)
{
Common.Log($"No IPv4 resolved from the local machine: {Common.MachineName}");
return true;
@@ -1234,6 +1234,8 @@ namespace MouseWithoutBorders.Class
}
private long lastRemoteMachineID;
internal static readonly string[] Separator = new string[] { "\r\n" };
internal static readonly char[] BlankSeparator = new char[] { ' ' };
private void MainTCPRoutine(TcpSk tcp, string machineName, bool isClient)
{

View File

@@ -104,6 +104,7 @@ namespace MouseWithoutBorders.Class
}
private static bool logged;
internal static readonly string[] Separator = new[] { " " };
private void LogError(string log)
{
@@ -146,7 +147,7 @@ namespace MouseWithoutBorders.Class
try
{
// Assuming the format of netstat's output is fixed.
pid = int.Parse(portLogLine.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last(), CultureInfo.CurrentCulture);
pid = int.Parse(portLogLine.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Last(), CultureInfo.CurrentCulture);
process = Process.GetProcessById(pid);
}
catch (Exception)

View File

@@ -123,13 +123,14 @@ namespace MouseWithoutBorders
}
private string lastMessage = string.Empty;
private static readonly string[] Separator = new string[] { "\r\n" };
internal void ShowTip(ToolTipIcon icon, string msg, int durationInMilliseconds)
{
int x = 0;
string text = msg + $"\r\n {(lastMessage.Equals(msg, StringComparison.OrdinalIgnoreCase) ? string.Empty : $"\r\nPrevious message/error: {lastMessage}")} ";
lastMessage = msg;
int y = (-text.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length * 15) - 30;
int y = (-text.Split(Separator, StringSplitOptions.None).Length * 15) - 30;
toolTipManual.Hide(this);

View File

@@ -742,11 +742,13 @@ namespace MouseWithoutBorders
LoadMachines();
}
internal static readonly string[] Separator = new string[] { "\r\n" };
internal void ShowTip(ToolTipIcon icon, string text, int duration)
{
int x = 0;
text += "\r\n ";
int y = (-text.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length * 15) - 30;
int y = (-text.Split(Separator, StringSplitOptions.None).Length * 15) - 30;
toolTipManual.Hide(this);

View File

@@ -8,8 +8,8 @@
<UseWindowsForms>true</UseWindowsForms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AssemblyName>PowerToys.MouseWithoutBordersHelper</AssemblyName>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<AssemblyName>PowerToys.MouseWithoutBordersHelper</AssemblyName>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<OutputPath>..\..\..\..\..\$(Platform)\$(Configuration)</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -49,12 +49,12 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="Resources\**" />
<Compile Remove="Service\**" />
<Compile Remove="Service\**" />
<EmbeddedResource Remove="Resources\**" />
<EmbeddedResource Remove="Service\**" />
<ExcludeFromStyleCop Remove="Service\**" />
<EmbeddedResource Remove="Service\**" />
<ExcludeFromStyleCop Remove="Service\**" />
<None Remove="Resources\**" />
<None Remove="Service\**" />
<None Remove="Service\**" />
</ItemGroup>
<ItemGroup>
@@ -69,6 +69,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="StreamJsonRpc" />

View File

@@ -8,8 +8,8 @@
<UseWindowsForms>true</UseWindowsForms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AssemblyName>PowerToys.MouseWithoutBorders</AssemblyName>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<AssemblyName>PowerToys.MouseWithoutBorders</AssemblyName>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -58,10 +58,10 @@
<Compile Remove="Service\**" />
<Compile Remove="Helper\**" />
<EmbeddedResource Remove="Resources\**" />
<EmbeddedResource Remove="Service\**" />
<ExcludeFromStyleCop Remove="Service\**" />
<EmbeddedResource Remove="Service\**" />
<ExcludeFromStyleCop Remove="Service\**" />
<None Remove="Resources\**" />
<None Remove="Service\**" />
<None Remove="Service\**" />
</ItemGroup>
<ItemGroup>
<Compile Update="Control\ColorBorderField.cs">
@@ -214,6 +214,8 @@
<Content Include="Logo.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" />

View File

@@ -74,6 +74,8 @@
<None Remove="Service\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="Microsoft.Windows.CsWinRT"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />

View File

@@ -148,6 +148,8 @@ internal sealed class ImageMethods
return resultText.Trim();
}
internal static readonly char[] Separator = new char[] { '\n', '\r' };
public static async Task<string> ExtractText(Bitmap bmp, Language? preferredLanguage, System.Windows.Point? singlePoint = null)
{
Language? selectedLanguage = preferredLanguage ?? GetOCRLanguage();
@@ -211,7 +213,7 @@ internal sealed class ImageMethods
if (culture.TextInfo.IsRightToLeft)
{
string[] textListLines = text.ToString().Split(new char[] { '\n', '\r' });
string[] textListLines = text.ToString().Split(Separator);
_ = text.Clear();
foreach (string textLine in textListLines)

View File

@@ -239,7 +239,7 @@ public class ResultTable
return rowAreas;
}
private static void CheckIntersectionsWithWordBorders(int hitGridSpacing, ICollection<WordBorder> wordBorders, ICollection<int> rowAreas, int i, Rect horizontalLineRect)
private static void CheckIntersectionsWithWordBorders(int hitGridSpacing, ICollection<WordBorder> wordBorders, List<int> rowAreas, int i, Rect horizontalLineRect)
{
foreach (WordBorder wb in wordBorders)
{

View File

@@ -50,15 +50,7 @@ public partial class OCROverlay : Window
InitializeComponent();
// workaround for #30177
try
{
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, Wpf.Ui.Controls.WindowBackdropType.None);
}
catch (Exception ex)
{
Logger.LogError($"Exception in SystemThemeWatcher.Watch, issue 30177. {ex.Message}");
}
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, Wpf.Ui.Controls.WindowBackdropType.None);
PopulateLanguageMenu();
}

View File

@@ -16,7 +16,7 @@ namespace PowerOCR.Settings
[Export(typeof(IUserSettings))]
public class UserSettings : IUserSettings
{
private readonly ISettingsUtils _settingsUtils;
private readonly SettingsUtils _settingsUtils;
private const string PowerOcrModuleName = "TextExtractor";
private const string DefaultActivationShortcut = "Win + Shift + O";
private const int MaxNumberOfRetry = 5;

View File

@@ -0,0 +1,41 @@
#include <windows.h>
#include "resource.h"
#include "../../../../common/version/version.h"
#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
#undef APSTUDIO_READONLY_SYMBOLS
1 VERSIONINFO
FILEVERSION FILE_VERSION
PRODUCTVERSION PRODUCT_VERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION
VALUE "FileVersion", FILE_VERSION_STRING
VALUE "InternalName", INTERNAL_NAME
VALUE "LegalCopyright", COPYRIGHT_NOTE
VALUE "OriginalFilename", ORIGINAL_FILENAME
VALUE "ProductName", PRODUCT_NAME
VALUE "ProductVersion", PRODUCT_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@@ -8,6 +8,10 @@
#include <common/utils/winapi_error.h>
#include <common/utils/process_path.h>
#include <common/utils/elevation.h>
#include <common/notifications/NotificationUtil.h>
#include <Generated Files/resource.h>
#include <interop/shared_constants.h>
#include <trace.h>
@@ -489,6 +493,10 @@ void AlwaysOnTop::HandleWinHookEvent(WinHookEvent* data) noexcept
break;
case EVENT_SYSTEM_FOREGROUND:
{
if (!is_process_elevated() && IsProcessOfWindowElevated(data->hwnd))
{
notifications::WarnIfElevationIsRequired(GET_RESOURCE_STRING(IDS_ALWAYSONTOP), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_LEARN_MORE), GET_RESOURCE_STRING(IDS_SYSTEM_FOREGROUND_ELEVATED_DIALOG_DONT_SHOW_AGAIN));
}
RefreshBorders();
}
break;

View File

@@ -3,6 +3,9 @@
<!-- Project configurations -->
<!-- Props that should be disabled while building on CI server -->
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h AlwaysOnTop.base.rc AlwaysOnTop.rc" />
</Target>
<ItemDefinitionGroup Condition="'$(CIBuild)'!='true'">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -141,9 +144,12 @@
<ItemGroup>
<ClInclude Include="AlwaysOnTop.h" />
<ClInclude Include="FrameDrawer.h" />
<ClInclude Include="Generated Files/resource.h" />
<ClInclude Include="ModuleConstants.h" />
<ClInclude Include="NotificationUtil.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
<None Include="resource.base.h" />
<ClInclude Include="ScalingUtils.h" />
<ClInclude Include="Settings.h" />
<ClInclude Include="SettingsConstants.h" />
@@ -167,10 +173,17 @@
</ProjectReference>
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\notifications\notifications.vcxproj">
<Project>{1d5be09d-78c0-4fd7-af00-ae7c1af7c525}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AlwaysOnTop.rc" />
<ResourceCompile Include="Generated Files/AlwaysOnTop.rc" />
<None Include="AlwaysOnTop.base.rc" />
</ItemGroup>
<ItemGroup>
<None Include="Resources.resx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />

View File

@@ -12,6 +12,9 @@
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Generated Files">
<UniqueIdentifier>{A74B5AAC-E913-410D-8941-D73346CF47AE}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
@@ -49,8 +52,22 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Generated Files/AlwaysOnTop.rc">
<Filter>Generated Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources.resx">
<Filter>Resource Files</Filter>
</None>
<None Include="resource.base.h">
<Filter>Header Files</Filter>
</None>
<None Include="AlwaysOnTop.base.rc">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
@@ -97,6 +114,9 @@
</ClInclude>
<ClInclude Include="ScalingUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Generated Files/resource.h">
<Filter>Generated Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AlwaysOnTop" xml:space="preserve">
<value>AlwaysOnTop</value>
<comment>AlwaysOnTop is a product name, keep as is.</comment>
</data>
<data name="System_Foreground_Elevated" xml:space="preserve">
<value>We've detected an application running with administrator privileges. This will prevent certain interactions with these applications.</value>
<comment>administrator is context of user account.</comment>
</data>
<data name="System_Foreground_Elevated_Learn_More" xml:space="preserve">
<value>Learn more</value>
</data>
<data name="System_Foreground_Elevated_Dialog_Dont_Show_Again" xml:space="preserve">
<value>Don't show again</value>
</data>
</root>

View File

@@ -0,0 +1,13 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AlwaysOnTop.rc
//////////////////////////////
// Non-localizable
#define FILE_DESCRIPTION "PowerToys.AlwaysOnTop"
#define INTERNAL_NAME "PowerToys.AlwaysOnTop"
#define ORIGINAL_FILENAME "PowerToys.AlwaysOnTop.exe"
// Non-localizable
//////////////////////////////

View File

@@ -28,6 +28,9 @@ namespace Awake.Core
/// </summary>
public class Manager
{
private static readonly CompositeFormat AwakeMinutes = System.Text.CompositeFormat.Parse(Properties.Resources.AWAKE_MINUTES);
private static readonly CompositeFormat AwakeHours = System.Text.CompositeFormat.Parse(Properties.Resources.AWAKE_HOURS);
private static BlockingCollection<ExecutionState> _stateQueue;
private static CancellationTokenSource _tokenSource;
@@ -276,9 +279,9 @@ namespace Awake.Core
{
Dictionary<string, int> optionsList = new Dictionary<string, int>
{
{ string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_MINUTES, 30), 1800 },
{ string.Format(CultureInfo.InvariantCulture, AwakeMinutes, 30), 1800 },
{ Resources.AWAKE_1_HOUR, 3600 },
{ string.Format(CultureInfo.InvariantCulture, Resources.AWAKE_HOURS, 2), 7200 },
{ string.Format(CultureInfo.InvariantCulture, AwakeHours, 2), 7200 },
};
return optionsList;
}

View File

@@ -47,6 +47,11 @@ namespace Awake
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private static ManualResetEvent _exitSignal = new ManualResetEvent(false);
internal static readonly string[] AliasesConfigOption = new[] { "--use-pt-config", "-c" };
internal static readonly string[] AliasesDisplayOption = new[] { "--display-on", "-d" };
internal static readonly string[] AliasesTimeOption = new[] { "--time-limit", "-t" };
internal static readonly string[] AliasesPidOption = new[] { "--pid", "-p" };
internal static readonly string[] AliasesExpireAtOption = new[] { "--expire-at", "-e" };
private static int Main(string[] args)
{
@@ -86,7 +91,7 @@ namespace Awake
Logger.LogInfo("Parsing parameters...");
Option<bool> configOption = new(
aliases: new[] { "--use-pt-config", "-c" },
aliases: AliasesConfigOption,
getDefaultValue: () => false,
description: $"Specifies whether {Core.Constants.AppName} will be using the PowerToys configuration file for managing the state.")
{
@@ -95,7 +100,7 @@ namespace Awake
};
Option<bool> displayOption = new(
aliases: new[] { "--display-on", "-d" },
aliases: AliasesDisplayOption,
getDefaultValue: () => true,
description: "Determines whether the display should be kept awake.")
{
@@ -104,7 +109,7 @@ namespace Awake
};
Option<uint> timeOption = new(
aliases: new[] { "--time-limit", "-t" },
aliases: AliasesTimeOption,
getDefaultValue: () => 0,
description: "Determines the interval, in seconds, during which the computer is kept awake.")
{
@@ -113,7 +118,7 @@ namespace Awake
};
Option<int> pidOption = new(
aliases: new[] { "--pid", "-p" },
aliases: AliasesPidOption,
getDefaultValue: () => 0,
description: $"Bind the execution of {Core.Constants.AppName} to another process. When the process ends, the system will resume managing the current sleep and display state.")
{
@@ -122,7 +127,7 @@ namespace Awake
};
Option<string> expireAtOption = new(
aliases: new[] { "--expire-at", "-e" },
aliases: AliasesExpireAtOption,
getDefaultValue: () => string.Empty,
description: $"Determines the end date/time when {Core.Constants.AppName} will back off and let the system manage the current sleep and display state.")
{

View File

@@ -0,0 +1,67 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\Version.props" />
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>Microsoft Corporation</Authors>
<Product>PowerToys</Product>
<Nullable>enable</Nullable>
<Description>PowerToys CommandNotFound</Description>
<AssemblyName>PowerToys.CmdNotFound</AssemblyName>
<GenerateDependencyFile>false</GenerateDependencyFile>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<SelfContained>true</SelfContained>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>
<!-- SelfContained=true requires RuntimeIdentifier to be set -->
<PropertyGroup Condition="'$(Platform)'=='x64'">
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='ARM64'">
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>TRACE;RELEASE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.ObjectPool">
<ExcludeAssets>contentFiles</ExcludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Management.Automation">
<ExcludeAssets>contentFiles</ExcludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Content Include="WinGetCommandNotFound.psd1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\ManagedTelemetry.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,57 @@
// 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.Management.Automation;
using System.Management.Automation.Subsystem;
using System.Management.Automation.Subsystem.Feedback;
using System.Management.Automation.Subsystem.Prediction;
namespace WinGetCommandNotFound
{
public sealed class Init : IModuleAssemblyInitializer, IModuleAssemblyCleanup
{
internal const string Id = "e5351aa4-dfde-4d4d-bf0f-1a2f5a37d8d6";
public void OnImport()
{
if (!Platform.IsWindows || !IsWinGetInstalled())
{
return;
}
SubsystemManager.RegisterSubsystem(SubsystemKind.FeedbackProvider, WinGetCommandNotFoundFeedbackPredictor.Singleton);
SubsystemManager.RegisterSubsystem(SubsystemKind.CommandPredictor, WinGetCommandNotFoundFeedbackPredictor.Singleton);
}
public void OnRemove(PSModuleInfo psModuleInfo)
{
if (!IsWinGetInstalled())
{
return;
}
SubsystemManager.UnregisterSubsystem<IFeedbackProvider>(new Guid(Id));
SubsystemManager.UnregisterSubsystem<ICommandPredictor>(new Guid(Id));
}
private bool IsWinGetInstalled()
{
// Ensure WinGet is installed
using (var pwsh = PowerShell.Create(RunspaceMode.CurrentRunspace))
{
var results = pwsh.AddCommand("Get-Command")
.AddParameter("Name", "winget")
.AddParameter("CommandType", "Application")
.Invoke();
if (results.Count is 0)
{
return false;
}
}
return true;
}
}
}

View File

@@ -0,0 +1,34 @@
// 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.Management.Automation;
using System.Management.Automation.Runspaces;
using Microsoft.Extensions.ObjectPool;
namespace WinGetCommandNotFound
{
public sealed class PooledPowerShellObjectPolicy : IPooledObjectPolicy<PowerShell>
{
private static readonly string[] WingetClientModuleName = new[] { "Microsoft.WinGet.Client" };
public PowerShell Create()
{
var iss = InitialSessionState.CreateDefault2();
iss.ImportPSModule(WingetClientModuleName);
return PowerShell.Create(iss);
}
public bool Return(PowerShell obj)
{
if (obj != null)
{
obj.Commands.Clear();
obj.Streams.ClearStreams();
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,16 @@
// 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.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace WinGetCommandNotFound.Telemetry
{
[EventData]
public class CmdNotFoundFeedbackProvidedEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -0,0 +1,16 @@
// 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.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace WinGetCommandNotFound.Telemetry
{
[EventData]
public class CmdNotFoundSuggestionProvidedEvent : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -0,0 +1,11 @@
@{
ModuleVersion = '0.1.0'
GUID = '28c9afa2-92e5-413e-8e53-44b2d7a83ac6'
Author = 'Carlos Zamora'
CompanyName = "Microsoft Corporation"
Copyright = "Copyright (c) Microsoft Corporation."
Description = 'Enable suggestions on how to install missing commands via winget'
PowerShellVersion = '7.4'
NestedModules = @('PowerToys.CmdNotFound.dll')
RequiredModules = @(@{ModuleName = 'Microsoft.WinGet.Client'; ModuleVersion = "0.2.1"; })
}

View File

@@ -0,0 +1,206 @@
// 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;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Management.Automation;
using System.Management.Automation.Subsystem.Feedback;
using System.Management.Automation.Subsystem.Prediction;
using Microsoft.Extensions.ObjectPool;
using Microsoft.PowerToys.Telemetry;
namespace WinGetCommandNotFound
{
public sealed class WinGetCommandNotFoundFeedbackPredictor : IFeedbackProvider, ICommandPredictor
{
private readonly Guid _guid;
private readonly ObjectPool<PowerShell> _pool;
private const int _maxSuggestions = 20;
private List<string>? _candidates;
private bool _warmedUp;
public static WinGetCommandNotFoundFeedbackPredictor Singleton { get; } = new WinGetCommandNotFoundFeedbackPredictor(Init.Id);
private WinGetCommandNotFoundFeedbackPredictor(string guid)
{
_guid = new Guid(guid);
var provider = new DefaultObjectPoolProvider();
_pool = provider.Create(new PooledPowerShellObjectPolicy());
_pool.Return(_pool.Get());
Task.Run(() => WarmUp());
}
public Guid Id => _guid;
public string Name => "Windows Package Manager - WinGet";
public string Description => "Finds missing commands that can be installed via WinGet.";
public Dictionary<string, string>? FunctionsToDefine => null;
private void WarmUp()
{
var ps = _pool.Get();
try
{
ps.AddCommand("Find-WinGetPackage")
.AddParameter("Count", 1)
.Invoke();
}
finally
{
_pool.Return(ps);
_warmedUp = true;
}
}
/// <summary>
/// Gets feedback based on the given commandline and error record.
/// </summary>
public FeedbackItem? GetFeedback(FeedbackContext context, CancellationToken token)
{
var target = (string)context.LastError!.TargetObject;
if (target is not null)
{
bool tooManySuggestions = false;
string packageMatchFilterField = "command";
var pkgList = FindPackages(target, ref tooManySuggestions, ref packageMatchFilterField);
if (pkgList.Count == 0)
{
return null;
}
// Build list of suggestions
_candidates = new List<string>();
foreach (var pkg in pkgList)
{
_candidates.Add(string.Format(CultureInfo.InvariantCulture, "winget install --id {0}", pkg.Members["Id"].Value.ToString()));
}
// Build footer message
var footerMessage = tooManySuggestions ?
string.Format(CultureInfo.InvariantCulture, "Additional results can be found using \"winget search --{0} {1}\"", packageMatchFilterField, target) :
null;
PowerToysTelemetry.Log.WriteEvent(new Telemetry.CmdNotFoundFeedbackProvidedEvent());
return new FeedbackItem(
"Try installing this package using winget:",
_candidates,
footerMessage,
FeedbackDisplayLayout.Portrait);
}
return null;
}
private Collection<PSObject> FindPackages(string query, ref bool tooManySuggestions, ref string packageMatchFilterField)
{
if (!_warmedUp)
{
return new Collection<PSObject>();
}
var ps = _pool.Get();
try
{
var common = new Hashtable()
{
["Source"] = "winget",
};
// 1) Search by command
var pkgList = ps.AddCommand("Find-WinGetPackage")
.AddParameter("Command", query)
.AddParameter("MatchOption", "StartsWithCaseInsensitive")
.AddParameters(common)
.Invoke();
if (pkgList.Count > 0)
{
tooManySuggestions = pkgList.Count > _maxSuggestions;
packageMatchFilterField = "command";
return pkgList;
}
// 2) No matches found,
// search by name
ps.Commands.Clear();
pkgList = ps.AddCommand("Find-WinGetPackage")
.AddParameter("Name", query)
.AddParameter("MatchOption", "ContainsCaseInsensitive")
.AddParameters(common)
.Invoke();
if (pkgList.Count > 0)
{
tooManySuggestions = pkgList.Count > _maxSuggestions;
packageMatchFilterField = "name";
return pkgList;
}
// 3) No matches found,
// search by moniker
ps.Commands.Clear();
pkgList = ps.AddCommand("Find-WinGetPackage")
.AddParameter("Moniker", query)
.AddParameter("MatchOption", "ContainsCaseInsensitive")
.AddParameters(common)
.Invoke();
tooManySuggestions = pkgList.Count > _maxSuggestions;
packageMatchFilterField = "moniker";
return pkgList;
}
finally
{
_pool.Return(ps);
}
}
public bool CanAcceptFeedback(PredictionClient client, PredictorFeedbackKind feedback)
{
return feedback switch
{
PredictorFeedbackKind.CommandLineAccepted => true,
_ => false,
};
}
public SuggestionPackage GetSuggestion(PredictionClient client, PredictionContext context, CancellationToken cancellationToken)
{
if (_candidates is not null)
{
string input = context.InputAst.Extent.Text;
List<PredictiveSuggestion>? result = null;
foreach (string c in _candidates)
{
if (c.StartsWith(input, StringComparison.OrdinalIgnoreCase))
{
result ??= new List<PredictiveSuggestion>(_candidates.Count);
result.Add(new PredictiveSuggestion(c));
}
}
if (result is not null)
{
PowerToysTelemetry.Log.WriteEvent(new Telemetry.CmdNotFoundSuggestionProvidedEvent());
return new SuggestionPackage(result);
}
}
return default;
}
public void OnCommandLineAccepted(PredictionClient client, IReadOnlyList<string> history)
{
// Reset the candidate state.
_candidates = null;
}
}
}

View File

@@ -0,0 +1,108 @@
// Microsoft Visual C++ generated resource script.
//
#include <windows.h>
#include "resource.h"
#include "../../../common/version/version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
1 VERSIONINFO
FILEVERSION FILE_VERSION
PRODUCTVERSION PRODUCT_VERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0" // US English (0x0409), Unicode (0x04B0) charset
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION
VALUE "FileVersion", FILE_VERSION_STRING
VALUE "InternalName", INTERNAL_NAME
VALUE "LegalCopyright", COPYRIGHT_NOTE
VALUE "OriginalFilename", ORIGINAL_FILENAME
VALUE "ProductName", PRODUCT_NAME
VALUE "ProductVersion", PRODUCT_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200 // US English (0x0409), Unicode (1200) charset
END
END
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_CMD_NOT_FOUND_NAME "Command Not Found"
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{0014d652-901f-4456-8d65-06fc5f997fb0}</ProjectGuid>
<RootNamespace>CmdNotFoundModuleInterface</RootNamespace>
<TargetName>PowerToys.CmdNotFoundModuleInterface</TargetName>
<PlatformToolset>v143</PlatformToolset>
<ProjectName>CmdNotFoundModuleInterface</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;CMDNOTFOUNDMODULEINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Shlwapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;CMDNOTFOUNDMODULEINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Shlwapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\common\Telemetry;..\..\;..\..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="trace.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\SettingsAPI\SettingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CmdNotFoundModuleInterface.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="trace.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CmdNotFoundModuleInterface.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,143 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <filesystem>
#include <string>
#include <common/logger/logger.h>
#include <common/logger/logger_settings.h>
#include <common/SettingsAPI/settings_objects.h>
#include <common/utils/gpo.h>
#include <common/utils/logger_helper.h>
#include <common/utils/process_path.h>
#include <common/utils/resources.h>
#include <interface/powertoy_module_interface.h>
#include "resource.h"
#include "trace.h"
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;
}
const static wchar_t* MODULE_NAME = L"Command Not Found";
const static wchar_t* MODULE_DESC = L"A module that detects an error thrown by a command in PowerShell and suggests a relevant WinGet package to install, if available.";
inline const std::wstring ModuleKey = L"CmdNotFound";
class CmdNotFound : public PowertoyModuleIface
{
std::wstring app_name;
std::wstring app_key;
private:
bool m_enabled = false;
void install_module()
{
auto module_path = get_module_folderpath();
std::string command = "pwsh.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(module_path) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\EnableModule.ps1" + "\"" + " -scriptPath \"" + winrt::to_string(module_path) + "\"";
system(command.c_str());
Trace::EnableCmdNotFoundGpo(true);
}
void uninstall_module()
{
auto module_path = get_module_folderpath();
std::string command = "pwsh.exe";
command += " ";
command += "-NoProfile -NonInteractive -NoLogo -WindowStyle Hidden -ExecutionPolicy Unrestricted -File \"" + winrt::to_string(module_path) + "\\WinUI3Apps\\Assets\\Settings\\Scripts\\DisableModule.ps1" + "\"";
system(command.c_str());
Trace::EnableCmdNotFoundGpo(false);
}
public:
CmdNotFound()
{
app_name = GET_RESOURCE_STRING(IDS_CMD_NOT_FOUND_NAME);
app_key = ModuleKey;
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(this->app_key));
logFilePath.append(LogSettings::cmdNotFoundLogPath);
Logger::init(LogSettings::cmdNotFoundLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
Logger::info("CmdNotFound object is constructing");
powertoys_gpo::gpo_rule_configured_t gpo_rule_configured_value = gpo_policy_enabled_configuration();
if (gpo_rule_configured_value == powertoys_gpo::gpo_rule_configured_t::gpo_rule_configured_enabled)
{
install_module();
m_enabled = true;
}
else if (gpo_rule_configured_value == powertoys_gpo::gpo_rule_configured_t::gpo_rule_configured_disabled)
{
uninstall_module();
m_enabled = false;
}
}
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
{
return powertoys_gpo::getConfiguredCmdNotFoundEnabledValue();
}
virtual void destroy() override
{
delete this;
}
virtual const wchar_t* get_name() override
{
return MODULE_NAME;
}
virtual const wchar_t* get_key() override
{
return app_key.c_str();
}
virtual bool get_config(wchar_t* /*buffer*/, int* /*buffer_size*/) override
{
return false;
}
virtual void set_config(const wchar_t* config) override
{
}
virtual void enable()
{
}
virtual void disable()
{
}
virtual bool is_enabled() override
{
return m_enabled;
}
};
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
{
return new CmdNotFound();
}

View File

@@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@@ -0,0 +1,16 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
#include <ProjectTelemetry.h>
#endif //PCH_H

View File

@@ -0,0 +1,21 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Awake.rc
//
#define IDS_CMD_NOT_FOUND_NAME 101
#define FILE_DESCRIPTION "PowerToys Command Not Found"
#define INTERNAL_NAME "PowerToys.CmdNotFoundModuleInterface"
#define ORIGINAL_FILENAME "PowerToys.CmdNotFoundModuleInterface.dll"
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More