Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New PowerToy] Create new OCR PowerToy #19172

Merged
merged 81 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
390d9cf
Init commit
TheJoeFin Jul 4, 2022
0ddb1c4
Fix unintended GUID change of Microsoft.PowerToys.Run.Plugin.TimeZone…
TheJoeFin Jul 4, 2022
41699d3
Region and click word working
TheJoeFin Jul 5, 2022
6b9eba8
Code style
TheJoeFin Jul 5, 2022
a0fb725
Close even when there is no result from the OCR
TheJoeFin Jul 5, 2022
a1ec4c9
Fix spelling concerns, and make overlay black to match snipping tool
TheJoeFin Jul 6, 2022
f84b5ba
increase opacity of overlay to match snipping tool
TheJoeFin Jul 6, 2022
612e4e5
Code Style and cleanup
TheJoeFin Jul 6, 2022
c915e44
Code style
TheJoeFin Jul 6, 2022
8325ba9
Create Logos and hook them into the project file
TheJoeFin Jul 9, 2022
11a7ab6
Make the PowerOCR VCXProj more like Awake VCXProj
TheJoeFin Jul 10, 2022
cbcce05
Rename MainWindow to OCROverlay
TheJoeFin Jul 10, 2022
a614491
Add WindowUtilities and WindowForms
TheJoeFin Jul 10, 2022
82d8d77
Remove fsg to fix spelling error
TheJoeFin Jul 10, 2022
cbe6245
launch OCR Overlay on every screen
TheJoeFin Jul 10, 2022
0096230
Add PowerOCR to Runner Main.cpp
TheJoeFin Jul 10, 2022
9c37a9d
Add PowerOCR Settings and Properties
TheJoeFin Jul 10, 2022
45efdea
Add PowerOcrViewModel
TheJoeFin Jul 10, 2022
1df892b
Fix wrong setting reference in PowerOcrSettingsVM
TheJoeFin Jul 12, 2022
7df0983
Try to clean up the Cpp project for PowerOCR
TheJoeFin Jul 12, 2022
2f7e0a4
Went to ARM64 was x64 thanks @snickler
TheJoeFin Jul 13, 2022
c15f67f
Clean up PowerOCR C++ Proj with file refs
TheJoeFin Jul 13, 2022
0631501
Rewrite C++ dllmain comparing to awake
TheJoeFin Jul 13, 2022
66662d5
Changes for spelling issues. The rest will stay
TheJoeFin Jul 14, 2022
73a3973
Create PowerOcr Settings Page and add to settings shell
TheJoeFin Jul 14, 2022
6b425c2
Fix PowerOcr Settings
TheJoeFin Jul 15, 2022
8b9badc
Fix multi-monitor scaling issue
TheJoeFin Jul 15, 2022
13baf3a
Add close all overlays when escaping
TheJoeFin Jul 15, 2022
5f7b901
Update src/runner/main.cpp to call correct Power OCR dll
TheJoeFin Jul 18, 2022
b4dd0ee
Update expect.txt
crutkas Jul 18, 2022
ca3ab9a
Add many files from Color Picker for hotkey activation
TheJoeFin Jul 23, 2022
208e4d5
Organize project into helper folder
TheJoeFin Jul 23, 2022
3fafb0d
Use new hotkey activation and keep process alive
TheJoeFin Jul 23, 2022
5f5aec3
Fix bug where scalebmp wasn't working
TheJoeFin Jul 23, 2022
90a1d59
Add The file headers and dispose app.xaml.cs
TheJoeFin Jul 23, 2022
6597b82
Merge branch 'microsoft:main' into main
TheJoeFin Jul 23, 2022
f1e1055
Code style changes
TheJoeFin Jul 23, 2022
1bb7ff6
Fix bug where PowerOCR was toggling Awake
TheJoeFin Jul 24, 2022
44e3064
Unsubscribe from keyboard events making they don't fire twice
TheJoeFin Jul 24, 2022
1da03c3
Add SndPowerOcrSetting and add to SettingsVM
TheJoeFin Jul 24, 2022
b8a0ce4
Trying to make the runner close PowerOCR when runner closes
TheJoeFin Aug 4, 2022
0d267e9
Fix app_name
TheJoeFin Aug 4, 2022
71696f6
Update spellcheck expect
TheJoeFin Aug 4, 2022
aa3a065
use mutex on PowerOCR app to keep to single instance
TheJoeFin Aug 10, 2022
03ccc73
Sync upstream
TheJoeFin Aug 10, 2022
5c220ed
Merge branch 'microsoft:main' into main
TheJoeFin Aug 10, 2022
be9cb3b
Rebuild the module interface using ColorPicker as a template.
TheJoeFin Aug 13, 2022
fe3d310
Merge branch 'microsoft:main' into main
TheJoeFin Aug 13, 2022
a22ac15
Fix project names of the module interface
TheJoeFin Aug 14, 2022
ce11546
Put app startup args back to 0 like color picker
TheJoeFin Aug 14, 2022
8eb07a2
Runner now finds and enables/disables PowerOCR
TheJoeFin Aug 15, 2022
4b64848
remove unneeded item groups from settings proj, per stefansjfw
TheJoeFin Aug 16, 2022
262495f
Add PowerOCR Screenshots
TheJoeFin Aug 16, 2022
05a9b7d
Revert changed project GUID
TheJoeFin Aug 16, 2022
0176611
Merge branch 'microsoft:main' into main
TheJoeFin Aug 16, 2022
71de017
Add OOBE content for PowerOCR
TheJoeFin Aug 19, 2022
43f7a30
Keep cursor on one screen since the OCR window does not span screens.
TheJoeFin Aug 19, 2022
b59f42d
reload settings when activation key is pressed
TheJoeFin Aug 19, 2022
24e26c2
New screenshots and OOBE text
TheJoeFin Aug 20, 2022
8ce93ac
Merge branch 'microsoft:main' into main
TheJoeFin Aug 20, 2022
f11c9cb
Add PowerOCR as a case in the settings App.xaml.cs OnLaunched
TheJoeFin Aug 20, 2022
6f2c370
Settings and OOBE Text Changes
TheJoeFin Aug 21, 2022
4c98e95
Using using on bitmaps and change OCR overlay to stay open if no result
TheJoeFin Aug 21, 2022
f415e6c
Keyboard activation is handled is true
TheJoeFin Aug 21, 2022
ad4e07b
Remove unused start PowerOCR OOBE Method
TheJoeFin Aug 21, 2022
6076b61
[PowerOCR]Add some telemetry
jaimecbernardo Aug 22, 2022
cf89107
Add some logging
jaimecbernardo Aug 22, 2022
14af8d1
Don't recreate the OCR overlay Windows more times
jaimecbernardo Aug 22, 2022
e4588d2
Add to BugReportTool to get event viewer errors
jaimecbernardo Aug 22, 2022
50bce5a
Fix wrong comment
jaimecbernardo Aug 22, 2022
aa5b3b1
Fix another comment
jaimecbernardo Aug 22, 2022
05ab02f
Add files to installer
jaimecbernardo Aug 22, 2022
83ead1b
Add to signing
jaimecbernardo Aug 22, 2022
bf84066
Don't take Esc away from other apps
jaimecbernardo Aug 23, 2022
dab9926
Default to Win Shift R
jaimecbernardo Aug 23, 2022
d2896d6
Use low level keyboard hook from runner
jaimecbernardo Aug 23, 2022
3fc84b6
Remove esc from local low level keyboard hook
jaimecbernardo Aug 23, 2022
e1d5913
Merge branch 'main' into main
jaimecbernardo Aug 24, 2022
ec6cab0
Merge branch 'main' into main
jaimecbernardo Aug 24, 2022
9302213
Fix some nits
jaimecbernardo Aug 24, 2022
a279e30
Default to Win Shift T
jaimecbernardo Aug 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,7 @@ Objbase
OBJID
objidl
oblitum
ocr
odbc
odbccp
Oem
Expand Down Expand Up @@ -1473,6 +1474,7 @@ PARENTNOTIFY
PARENTRELATIVEEDITING
PARENTRELATIVEFORADDRESSBAR
PARENTRELATIVEPARSING
PArgb
parray
PARTIALCONFIRMATIONDIALOGTITLE
pathcch
Expand Down Expand Up @@ -1529,6 +1531,7 @@ POPUPWINDOW
posix
powercfg
powerlauncher
POWEROCR
powerpreview
powerrename
POWERRENAMECONTEXTMENU
Expand Down
8 changes: 4 additions & 4 deletions .pipelines/ESRPSigning_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"modules\\AlwaysOnTop\\PowerToys.AlwaysOnTop.exe",
"modules\\AlwaysOnTop\\PowerToys.AlwaysOnTopModuleInterface.dll",

"modules\\ColorPicker\\ColorPicker.dll",
"modules\\ColorPicker\\ColorPickerUI.dll",
"modules\\ColorPicker\\ColorPickerUI.exe",

"modules\\ColorPicker\\PowerToys.ColorPicker.dll",
"modules\\ColorPicker\\PowerToys.ColorPickerUI.dll",
"modules\\ColorPicker\\PowerToys.ColorPickerUI.exe",

"modules\\PowerOCR\\PowerToys.PowerOCRModuleInterface.dll",
"modules\\PowerOCR\\PowerToys.PowerOCR.dll",
"modules\\PowerOCR\\PowerToys.PowerOCR.exe",

"modules\\Awake\\PowerToys.AwakeModuleInterface.dll",
"modules\\Awake\\PowerToys.Awake.exe",
"modules\\Awake\\PowerToys.Awake.dll",
Expand Down
33 changes: 33 additions & 0 deletions PowerToys.sln
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageResizerContextMenu", "
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageResizerLib", "src\modules\imageresizer\ImageResizerLib\ImageResizerLib.vcxproj", "{18B3DB45-4FFE-4D01-97D6-5223FEEE1853}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PowerOCR", "PowerOCR", "{A50C70A6-2DA0-4027-B90E-B1A40755A8A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerOCR", "src\modules\PowerOCR\PowerOCR\PowerOCR.csproj", "{25C91A4E-BA4E-467A-85CD-8B62545BF674}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerOCRModuleInterface", "src\modules\PowerOCR\PowerOCRModuleInterface\PowerOCRModuleInterface.vcxproj", "{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plugin.History", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.History\Microsoft.PowerToys.Run.Plugin.History.csproj", "{212AD910-8488-4036-BE20-326931B75FB2}"
EndProject
Global
Expand Down Expand Up @@ -1634,6 +1640,30 @@ Global
{18B3DB45-4FFE-4D01-97D6-5223FEEE1853}.Release|x64.Build.0 = Release|x64
{18B3DB45-4FFE-4D01-97D6-5223FEEE1853}.Release|x86.ActiveCfg = Release|x64
{18B3DB45-4FFE-4D01-97D6-5223FEEE1853}.Release|x86.Build.0 = Release|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|ARM64.ActiveCfg = Debug|ARM64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|ARM64.Build.0 = Debug|ARM64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|x64.ActiveCfg = Debug|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|x64.Build.0 = Debug|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|x86.ActiveCfg = Debug|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Debug|x86.Build.0 = Debug|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|ARM64.ActiveCfg = Release|ARM64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|ARM64.Build.0 = Release|ARM64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|x64.ActiveCfg = Release|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|x64.Build.0 = Release|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|x86.ActiveCfg = Release|x64
{25C91A4E-BA4E-467A-85CD-8B62545BF674}.Release|x86.Build.0 = Release|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|ARM64.Build.0 = Debug|ARM64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|x64.ActiveCfg = Debug|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|x64.Build.0 = Debug|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|x86.ActiveCfg = Debug|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Debug|x86.Build.0 = Debug|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|ARM64.ActiveCfg = Release|ARM64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|ARM64.Build.0 = Release|ARM64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|x64.ActiveCfg = Release|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|x64.Build.0 = Release|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|x86.ActiveCfg = Release|x64
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1}.Release|x86.Build.0 = Release|x64
{212AD910-8488-4036-BE20-326931B75FB2}.Debug|ARM64.ActiveCfg = Debug|ARM64
{212AD910-8488-4036-BE20-326931B75FB2}.Debug|ARM64.Build.0 = Debug|ARM64
{212AD910-8488-4036-BE20-326931B75FB2}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -1784,6 +1814,9 @@ Global
{5A1DB2F0-0715-4B3B-98E6-79BC41540045} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
{93B72A06-C8BD-484F-A6F7-C9F280B150BF} = {6C7F47CC-2151-44A3-A546-41C70025132C}
{18B3DB45-4FFE-4D01-97D6-5223FEEE1853} = {6C7F47CC-2151-44A3-A546-41C70025132C}
{A50C70A6-2DA0-4027-B90E-B1A40755A8A5} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{25C91A4E-BA4E-467A-85CD-8B62545BF674} = {A50C70A6-2DA0-4027-B90E-B1A40755A8A5}
{6AB6A2D6-F859-4A82-9184-0BD29C9F07D1} = {A50C70A6-2DA0-4027-B90E-B1A40755A8A5}
{212AD910-8488-4036-BE20-326931B75FB2} = {4AFC9975-2456-4C70-94A4-84073C1CED93}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
19 changes: 16 additions & 3 deletions installer/PowerToysSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<?define KeyboardManagerProjectName="KeyboardManager"?>
<?define PowerRenameProjectName="PowerRename"?>
<?define ColorPickerProjectName="ColorPicker"?>
<?define PowerOCRProjectName="PowerOCR"?>
<?define VideoConferenceProjectName="VideoConference"?>
<?define AwakeProjectName="Awake"?>
<?define MouseUtilsProjectName="MouseUtils"?>
Expand Down Expand Up @@ -48,11 +49,11 @@

<?define SettingsV2Files=Ijwhost.dll;ColorCode.Core.dll;ColorCode.WinUI.dll;CommunityToolkit.Common.dll;CommunityToolkit.WinUI.dll;CommunityToolkit.WinUI.UI.Controls.Core.dll;CommunityToolkit.WinUI.UI.Controls.DataGrid.dll;CommunityToolkit.WinUI.UI.Controls.Input.dll;CommunityToolkit.WinUI.UI.Controls.Layout.dll;CommunityToolkit.WinUI.UI.Controls.Markdown.dll;CommunityToolkit.WinUI.UI.Controls.Media.dll;CommunityToolkit.WinUI.UI.Controls.Primitives.dll;CommunityToolkit.WinUI.UI.dll;icon.ico;Microsoft.Graphics.Canvas.Interop.dll;Microsoft.InteractiveExperiences.Projection.dll;Microsoft.Windows.ApplicationModel.DynamicDependency.Projection.dll;Microsoft.Windows.ApplicationModel.Resources.Projection.dll;Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll;Microsoft.Windows.AppLifecycle.Projection.dll;Microsoft.Windows.SDK.NET.dll;Microsoft.Windows.System.Power.Projection.dll;Microsoft.WindowsAppRuntime.Bootstrap.Net.dll;Microsoft.WinUI.dll;Microsoft.Xaml.Interactions.dll;Microsoft.Xaml.Interactivity.dll;PowerToys.Interop.dll;PowerToys.ManagedCommon.dll;System.Management.dll;PowerToys.ManagedTelemetry.dll;PowerToys.Settings.deps.json;PowerToys.Settings.dll;PowerToys.Settings.exe;PowerToys.Settings.runtimeconfig.json;PowerToys.Settings.UI.Lib.dll;resources.pri;System.IO.Abstractions.dll;System.Text.Json.dll;WinRT.Runtime.dll;Microsoft.Graphics.Canvas.dll;Microsoft.WindowsAppRuntime.Bootstrap.dll;CoreMessagingXP.dll;dcompi.dll;dwmcorei.dll;DwmSceneI.dll;DWriteCore.dll;marshal.dll;Microsoft.DirectManipulation.dll;Microsoft.InputStateManager.dll;Microsoft.Internal.FrameworkUdk.dll;Microsoft.UI.Composition.OSSupport.dll;Microsoft.UI.Input.dll;Microsoft.UI.Windowing.Core.dll;Microsoft.UI.Xaml.Controls.dll;Microsoft.UI.Xaml.Controls.pri;Microsoft.ui.xaml.dll;Microsoft.UI.Xaml.Internal.dll;Microsoft.UI.Xaml.Phone.dll;Microsoft.ui.xaml.resources.19h1.dll;Microsoft.ui.xaml.resources.common.dll;Microsoft.Web.WebView2.Core.dll;Microsoft.Windows.ApplicationModel.Resources.dll;Microsoft.Windows.AppNotifications.Projection.dll;Microsoft.Windows.PushNotifications.Projection.dll;Microsoft.Windows.System.Projection.dll;Microsoft.WindowsAppRuntime.dll;Microsoft.WindowsAppRuntime.Insights.Resource.dll;Microsoft.WindowsAppRuntime.Release.Net.dll;MRM.dll;PushNotificationsLongRunningTask.ProxyStub.dll;WindowsAppRuntime.png;WindowsAppSdk.AppxDeploymentExtensions.Desktop.dll;WinUIEdit.dll;wuceffectsi.dll?>

<?define SettingsV2AssetsModulesFiles=ColorPicker.png;FancyZones.png;AlwaysOnTop.png;Awake.png;ImageResizer.png;KBM.png;MouseUtils.png;PowerLauncher.png;PowerPreview.png;PowerRename.png;PT.png;ShortcutGuide.png;VideoConference.png?>
<?define SettingsV2AssetsModulesFiles=ColorPicker.png;FancyZones.png;AlwaysOnTop.png;Awake.png;ImageResizer.png;KBM.png;MouseUtils.png;PowerLauncher.png;PowerPreview.png;PowerRename.png;PT.png;ShortcutGuide.png;VideoConference.png;PowerOCR.png?>

<?define SettingsV2OOBEAssetsModulesFiles=ColorPicker.gif;AlwaysOnTop.png;Awake.png;FancyZones.gif;FileExplorer.png;ImageResizer.gif;KBM.gif;MouseUtils.gif;PowerRename.gif;Run.gif;OOBEShortcutGuide.png;VideoConferenceMute.png;OOBEPTHero.png?>
<?define SettingsV2OOBEAssetsModulesFiles=ColorPicker.gif;AlwaysOnTop.png;Awake.png;FancyZones.gif;FileExplorer.png;ImageResizer.gif;KBM.gif;MouseUtils.gif;PowerRename.gif;Run.gif;OOBEShortcutGuide.png;VideoConferenceMute.png;OOBEPTHero.png;PowerOCR.gif?>

<?define SettingsV2OOBEAssetsFluentIconsFiles=ColorPicker.png;FancyZones.png;AlwaysOnTop.png;Awake.png;FileExplorerPreview.png;FindMyMouse.png;ImageResizer.png;KeyboardManager.png;MouseHighlighter.png;MouseCrosshairs.png;MouseUtils.png;PowerRename.png;PowerToys.png;PowerToysRun.png;Settings.png;ShortcutGuide.png;VideoConferenceMute.png?>
<?define SettingsV2OOBEAssetsFluentIconsFiles=ColorPicker.png;FancyZones.png;AlwaysOnTop.png;Awake.png;FileExplorerPreview.png;FindMyMouse.png;ImageResizer.png;KeyboardManager.png;MouseHighlighter.png;MouseCrosshairs.png;MouseUtils.png;PowerRename.png;PowerToys.png;PowerToysRun.png;Settings.png;ShortcutGuide.png;VideoConferenceMute.png;PowerOcr.png?>

<?define SettingsV2MicrosoftUIXamlAssetsInstallFiles=NoiseAsset_256x256_PNG.png?>

Expand Down Expand Up @@ -431,6 +432,7 @@
<Directory Id="MonacoPreviewHandlerMonacoSRCFolder" Name="monacoSRC" />
</Directory>
<Directory Id="FancyZonesInstallFolder" Name="$(var.FancyZonesProjectName)" />
<Directory Id="PowerOCRInstallFolder" Name="$(var.PowerOCRProjectName)" />
<Directory Id="AwakeInstallFolder" Name="$(var.AwakeProjectName)">
<Directory Id="AwakeImagesFolder" Name="Images" />
</Directory>
Expand Down Expand Up @@ -894,6 +896,16 @@
</Component>
</DirectoryRef>

<!-- PowerOCR Resources -->
<DirectoryRef Id="PowerOCRInstallFolder" FileSource="$(var.BinDir)modules\$(var.PowerOCRProjectName)">
<!-- !Warning! Make sure to change Component Guid if you update the file list -->
<Component Id="Module_PowerOCR" Guid="5640A7E8-E165-4368-8F08-F8E1E9242BDD" Win64="yes">
<?foreach File in PowerToys.PowerOCR.dll;ControlzEx.dll;Ijwhost.dll;Microsoft.Windows.SDK.NET.dll;Microsoft.Xaml.Behaviors.dll;PowerToys.Common.UI.dll;PowerToys.Interop.dll;PowerToys.ManagedCommon.dll;PowerToys.ManagedTelemetry.dll;PowerToys.PowerOCR.deps.json;PowerToys.PowerOCR.exe;PowerToys.PowerOCR.runtimeconfig.json;PowerToys.PowerOCRModuleInterface.dll;PowerToys.Settings.UI.Lib.dll;System.ComponentModel.Composition.dll;System.IO.Abstractions.dll;System.Management.dll;System.Text.Json.dll;WinRT.Runtime.dll?>
<File Id="PowerOCRFile_$(var.File)" Source="$(var.BinDir)modules\$(var.PowerOCRProjectName)\$(var.File)" />
<?endforeach?>
</Component>
</DirectoryRef>

<!-- Awake -->
<DirectoryRef Id="AwakeInstallFolder" FileSource="$(var.BinDir)modules\$(var.AwakeProjectName)">
<!-- !Warning! Make sure to change Component Guid if you update the file list -->
Expand Down Expand Up @@ -1063,6 +1075,7 @@
<ComponentRef Id="Module_KeyboardManager" />
<ComponentRef Id="Module_KeyboardManager_Editor" />
<ComponentRef Id="Module_KeyboardManager_Engine" />
<ComponentRef Id="Module_PowerOCR" />
<ComponentRef Id="Module_ColorPicker" />
<ComponentRef Id="Module_ColorPicker_Icon"/>
<ComponentRef Id="Module_ColorPicker_Cursor"/>
Expand Down
5 changes: 5 additions & 0 deletions src/common/interop/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,13 @@ public
return gcnew String(CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT);
}

static String ^ ShowPowerOCRSharedEvent() {
return gcnew String(CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT);
}

static String ^ AwakeExitEvent() {
return gcnew String(CommonSharedConstants::AWAKE_EXIT_EVENT);
}

};
}
3 changes: 3 additions & 0 deletions src/common/interop/shared_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace CommonSharedConstants
// Path to the event used by AlwaysOnTop
const wchar_t ALWAYS_ON_TOP_PIN_EVENT[] = L"Local\\AlwaysOnTopPinEvent-892e0aa2-cfa8-4cc4-b196-ddeb32314ce8";

// Path to the event used by PowerOCR
const wchar_t SHOW_POWEROCR_SHARED_EVENT[] = L"Local\\PowerOCREvent-dc864e06-e1af-4ecc-9078-f98bee745e3a";

// Max DWORD for key code to disable keys.
const DWORD VK_DISABLED = 0x100;
}
2 changes: 2 additions & 0 deletions src/common/logger/logger_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct LogSettings
inline const static std::wstring fancyZonesOldLogPath = L"FancyZonesLogs\\"; // needed to clean up old logs
inline const static std::string shortcutGuideLoggerName = "shortcut-guide";
inline const static std::wstring shortcutGuideLogPath = L"ShortcutGuideLogs\\shortcut-guide-log.txt";
inline const static std::wstring powerOcrLogPath = L"Logs\\power-ocr-log.txt";
inline const static std::string keyboardManagerLoggerName = "keyboard-manager";
inline const static std::wstring keyboardManagerLogPath = L"Logs\\keyboard-manager-log.txt";
inline const static std::string findMyMouseLoggerName = "find-my-mouse";
Expand All @@ -31,6 +32,7 @@ struct LogSettings
inline const static std::string imageResizerLoggerName = "imageresizer";
inline const static std::string powerRenameLoggerName = "powerrename";
inline const static std::string alwaysOnTopLoggerName = "always-on-top";
inline const static std::string powerOcrLoggerName = "power-ocr";
inline const static std::wstring alwaysOnTopLogPath = L"always-on-top-log.txt";
inline const static int retention = 30;
std::wstring logLevel;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/PowerOCR/PowerOCR/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Application
x:Class="PowerOCR.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PowerOCR"
ShutdownMode="OnExplicitShutdown"
Exit="Application_Exit"
Startup="Application_Startup">
<Application.Resources />
</Application>
88 changes: 88 additions & 0 deletions src/modules/PowerOCR/PowerOCR/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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.Diagnostics;
using System.Threading;
using System.Windows;
using ManagedCommon;
using PowerOCR.Helpers;
using PowerOCR.Keyboard;
using PowerOCR.Settings;

namespace PowerOCR;

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application, IDisposable
{
private KeyboardMonitor? keyboardMonitor;
private EventMonitor? eventMonitor;
private Mutex? _instanceMutex;
private int _powerToysRunnerPid;

public void Dispose()
{
GC.SuppressFinalize(this);
keyboardMonitor?.Dispose();
}

private void Application_Startup(object sender, StartupEventArgs e)
{
// allow only one instance of PowerOCR
_instanceMutex = new Mutex(true, @"Local\PowerToys_PowerOCR_InstanceMutex", out bool createdNew);
if (!createdNew)
{
Logger.LogWarning("Another running PowerOCR instance was detected. Exiting Color Picker");
_instanceMutex = null;
Environment.Exit(0);
return;
}

if (e.Args?.Length > 0)
{
try
{
Logger.LogInfo($"PowerOCR started from the PowerToys Runner. Runner pid={_powerToysRunnerPid}");

_ = int.TryParse(e.Args[0], out _powerToysRunnerPid);
RunnerHelper.WaitForPowerToysRunner(_powerToysRunnerPid, () =>
{
Logger.LogInfo("PowerToys Runner exited. Exiting PowerOCR");
Environment.Exit(0);
});
var userSettings = new UserSettings(new Helpers.ThrottledActionInvoker());
eventMonitor = new EventMonitor();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
else
{
Logger.LogInfo($"PowerOCR started detached from PowerToys Runner.");
_powerToysRunnerPid = -1;
var userSettings = new UserSettings(new Helpers.ThrottledActionInvoker());
keyboardMonitor = new KeyboardMonitor(userSettings);
keyboardMonitor?.Start();
}
}

protected override void OnExit(ExitEventArgs e)
{
if (_instanceMutex != null)
{
_instanceMutex.ReleaseMutex();
}

base.OnExit(e);
}

private void Application_Exit(object sender, ExitEventArgs e)
{
Dispose();
}
}
57 changes: 57 additions & 0 deletions src/modules/PowerOCR/PowerOCR/Helpers/CursorClipper.cs
Original file line number Diff line number Diff line change
@@ -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;
using System.Windows;

namespace PowerOCR.Helpers;

/// <summary>
/// Functions to constrain the mouse cursor (typically used when dragging)
/// </summary>
public static class CursorClipper
{
/// <summary>
/// Constrain mouse cursor to the area of the specified UI element.
/// </summary>
/// <param name="element">Target UI element.</param>
/// <returns>True on success.</returns>
public static bool ClipCursor(FrameworkElement element)
{
const double dpi96 = 96.0;

var topLeft = element.PointToScreen(new Point(0, 0));

PresentationSource source = PresentationSource.FromVisual(element);
if (source?.CompositionTarget == null)
{
return false;
}

double dpiX = dpi96 * source.CompositionTarget.TransformToDevice.M11;
double dpiY = dpi96 * source.CompositionTarget.TransformToDevice.M22;

var width = (int)((element.ActualWidth + 1) * dpiX / dpi96);
var height = (int)((element.ActualHeight + 1) * dpiY / dpi96);

OSInterop.RECT rect = new OSInterop.RECT
{
Left = (int)topLeft.X,
Top = (int)topLeft.Y,
Right = (int)topLeft.X + width,
Bottom = (int)topLeft.Y + height,
};

return OSInterop.ClipCursor(ref rect);
}

/// <summary>
/// Remove any mouse cursor constraint.
/// </summary>
/// <returns>True on success.</returns>
public static bool UnClipCursor()
{
return OSInterop.ClipCursor(IntPtr.Zero);
}
}
12 changes: 12 additions & 0 deletions src/modules/PowerOCR/PowerOCR/Helpers/IThrottledActionInvoker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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;

namespace PowerOCR.Helpers;

public interface IThrottledActionInvoker
{
void ScheduleAction(Action action, int milliseconds);
}
Loading