mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-21 15:53:19 +00:00
Dependencies cleanup (#34011)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request - Removed `Vanara.PInvoke.*` packages used in Quick Accent in favor of `Microsoft.Windows.CsWin32` that is already in use for other utilities. - Removed `Microsoft.Windows.SDK.Contracts` package instanned only on MWB. This is not needed: https://learn.microsoft.com/windows/apps/desktop/modernize/desktop-to-uwp-enhance#modify-a-net-project-to-use-windows-runtime-apis - Cleaned up obsolete packages from `Directory.Packages.props`: I realized that uninstalling a NuGet package from all projects doesn't remove it from `Directory.Packages.props`. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] **Closes:** #xxx - [ ] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Manually tested Quick Accent
This commit is contained in:
parent
3798a101a6
commit
3e133ae8bd
@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
@ -17,10 +17,8 @@
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
|
||||
<PackageVersion Include="ControlzEx" Version="6.0.0" />
|
||||
<PackageVersion Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
|
||||
<PackageVersion Include="HelixToolkit" Version="2.24.0" />
|
||||
<PackageVersion Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
|
||||
<PackageVersion Include="HtmlAgilityPack" Version="1.11.57" />
|
||||
<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" />
|
||||
@ -28,7 +26,6 @@
|
||||
<PackageVersion Include="Markdig.Signed" Version="0.34.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.7" />
|
||||
<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" />
|
||||
@ -43,7 +40,6 @@
|
||||
<!-- CsWinRT version needs to be set to have a WinRT.Runtime.dll at the same version contained inside the NET SDK we're currently building on CI. -->
|
||||
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
|
||||
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
||||
<PackageVersion Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
|
||||
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
|
||||
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||
@ -51,7 +47,6 @@
|
||||
<!-- 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" Version="3.5.0" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageVersion Include="NLog" Version="5.0.4" />
|
||||
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageVersion Include="NLog.Schema" Version="5.2.8" />
|
||||
@ -86,8 +81,6 @@
|
||||
<PackageVersion Include="UnicodeInformation" Version="2.6.0" />
|
||||
<PackageVersion Include="UnitsNet" Version="5.50.0" />
|
||||
<PackageVersion Include="UTF.Unknown" Version="2.5.1" />
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
@ -1331,7 +1331,6 @@ EXHIBIT A -Mozilla Public License.
|
||||
- Microsoft.Windows.CsWin32 0.2.46-beta
|
||||
- Microsoft.Windows.CsWinRT 2.0.4
|
||||
- Microsoft.Windows.SDK.BuildTools 10.0.22621.2428
|
||||
- Microsoft.Windows.SDK.Contracts 10.0.19041.1
|
||||
- Microsoft.WindowsAppSDK 1.5.240428000
|
||||
- Microsoft.Xaml.Behaviors.WinUI.Managed 2.0.9
|
||||
- Microsoft.Xaml.Behaviors.Wpf 1.1.39
|
||||
@ -1366,7 +1365,5 @@ EXHIBIT A -Mozilla Public License.
|
||||
- UnicodeInformation 2.6.0
|
||||
- UnitsNet 5.50.0
|
||||
- UTF.Unknown 2.5.1
|
||||
- Vanara.PInvoke.Shell32 3.4.11
|
||||
- Vanara.PInvoke.User32 3.4.11
|
||||
- WinUIEx 2.2.0
|
||||
- WPF-UI 3.0.0
|
||||
|
@ -215,7 +215,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="Microsoft.Windows.Compatibility" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" />
|
||||
<PackageReference Include="StreamJsonRpc" />
|
||||
<PackageReference Include="System.Data.SqlClient" /> <!-- It's a dependency of Microsoft.Windows.Compatibility. We're adding it here to force it to the version specified in Directory.Packages.props -->
|
||||
</ItemGroup>
|
||||
|
@ -24,7 +24,7 @@ public struct Point
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public Point(Vanara.PInvoke.POINT point)
|
||||
public Point(System.Drawing.Point point)
|
||||
{
|
||||
X = point.X;
|
||||
Y = point.Y;
|
||||
@ -34,7 +34,7 @@ public struct Point
|
||||
|
||||
public double Y { get; init; }
|
||||
|
||||
public static implicit operator Point(Vanara.PInvoke.POINT point) => new Point(point.X, point.Y);
|
||||
public static implicit operator Point(System.Drawing.Point point) => new Point(point.X, point.Y);
|
||||
|
||||
public static Point operator /(Point point, double divider)
|
||||
{
|
||||
|
@ -0,0 +1,6 @@
|
||||
GetDpiForWindow
|
||||
GetGUIThreadInfo
|
||||
GetKeyState
|
||||
GetMonitorInfo
|
||||
MonitorFromWindow
|
||||
SendInput
|
@ -23,11 +23,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" />
|
||||
<PackageReference Include="UnicodeInformation" />
|
||||
<PackageReference Include="Vanara.PInvoke.User32" />
|
||||
<PackageReference Include="Vanara.PInvoke.Shell32" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -3,7 +3,10 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Vanara.PInvoke;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Graphics.Gdi;
|
||||
using Windows.Win32.UI.Input.KeyboardAndMouse;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace PowerAccent.Core.Tools;
|
||||
|
||||
@ -16,72 +19,98 @@ internal static class WindowsFunctions
|
||||
if (back)
|
||||
{
|
||||
// Split in 2 different SendInput (Powershell doesn't take back issue)
|
||||
var inputsBack = new User32.INPUT[]
|
||||
var inputsBack = new INPUT[]
|
||||
{
|
||||
new User32.INPUT { type = User32.INPUTTYPE.INPUT_KEYBOARD, ki = new User32.KEYBDINPUT { wVk = (ushort)User32.VK.VK_BACK } },
|
||||
new User32.INPUT { type = User32.INPUTTYPE.INPUT_KEYBOARD, ki = new User32.KEYBDINPUT { wVk = (ushort)User32.VK.VK_BACK, dwFlags = User32.KEYEVENTF.KEYEVENTF_KEYUP } },
|
||||
new INPUT
|
||||
{
|
||||
type = INPUT_TYPE.INPUT_KEYBOARD,
|
||||
Anonymous = new INPUT._Anonymous_e__Union
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wVk = VIRTUAL_KEY.VK_BACK,
|
||||
},
|
||||
},
|
||||
},
|
||||
new INPUT
|
||||
{
|
||||
type = INPUT_TYPE.INPUT_KEYBOARD,
|
||||
Anonymous = new INPUT._Anonymous_e__Union
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wVk = VIRTUAL_KEY.VK_BACK,
|
||||
dwFlags = KEYBD_EVENT_FLAGS.KEYEVENTF_KEYUP,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
var temp1 = User32.SendInput((uint)inputsBack.Length, inputsBack, sizeof(User32.INPUT));
|
||||
System.Threading.Thread.Sleep(1); // Some apps, like Terminal, need a little wait to process the sent backspace or they'll ignore it.
|
||||
_ = PInvoke.SendInput(inputsBack, Marshal.SizeOf<INPUT>());
|
||||
Thread.Sleep(1); // Some apps, like Terminal, need a little wait to process the sent backspace or they'll ignore it.
|
||||
}
|
||||
|
||||
foreach (char c in s)
|
||||
{
|
||||
// Letter
|
||||
var inputsInsert = new User32.INPUT[]
|
||||
var inputsInsert = new INPUT[]
|
||||
{
|
||||
new User32.INPUT { type = User32.INPUTTYPE.INPUT_KEYBOARD, ki = new User32.KEYBDINPUT { wVk = 0, dwFlags = User32.KEYEVENTF.KEYEVENTF_UNICODE, wScan = c } },
|
||||
new User32.INPUT { type = User32.INPUTTYPE.INPUT_KEYBOARD, ki = new User32.KEYBDINPUT { wVk = 0, dwFlags = User32.KEYEVENTF.KEYEVENTF_UNICODE | User32.KEYEVENTF.KEYEVENTF_KEYUP, wScan = c } },
|
||||
new INPUT
|
||||
{
|
||||
type = INPUT_TYPE.INPUT_KEYBOARD,
|
||||
Anonymous = new INPUT._Anonymous_e__Union
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wScan = c,
|
||||
dwFlags = KEYBD_EVENT_FLAGS.KEYEVENTF_UNICODE,
|
||||
},
|
||||
},
|
||||
},
|
||||
new INPUT
|
||||
{
|
||||
type = INPUT_TYPE.INPUT_KEYBOARD,
|
||||
Anonymous = new INPUT._Anonymous_e__Union
|
||||
{
|
||||
ki = new KEYBDINPUT
|
||||
{
|
||||
wScan = c,
|
||||
dwFlags = KEYBD_EVENT_FLAGS.KEYEVENTF_UNICODE | KEYBD_EVENT_FLAGS.KEYEVENTF_KEYUP,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
var temp2 = User32.SendInput((uint)inputsInsert.Length, inputsInsert, sizeof(User32.INPUT));
|
||||
|
||||
_ = PInvoke.SendInput(inputsInsert, Marshal.SizeOf<INPUT>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Point GetCaretPosition()
|
||||
{
|
||||
User32.GUITHREADINFO guiInfo = default;
|
||||
guiInfo.cbSize = (uint)Marshal.SizeOf(guiInfo);
|
||||
User32.GetGUIThreadInfo(0, ref guiInfo);
|
||||
POINT caretPosition = new POINT(guiInfo.rcCaret.left, guiInfo.rcCaret.top);
|
||||
User32.ClientToScreen(guiInfo.hwndCaret, ref caretPosition);
|
||||
|
||||
if (caretPosition.X == 0)
|
||||
{
|
||||
POINT testPoint;
|
||||
User32.GetCaretPos(out testPoint);
|
||||
return testPoint;
|
||||
}
|
||||
|
||||
return caretPosition;
|
||||
}
|
||||
|
||||
public static (Point Location, Size Size, double Dpi) GetActiveDisplay()
|
||||
{
|
||||
User32.GUITHREADINFO guiInfo = default;
|
||||
GUITHREADINFO guiInfo = default;
|
||||
guiInfo.cbSize = (uint)Marshal.SizeOf(guiInfo);
|
||||
User32.GetGUIThreadInfo(0, ref guiInfo);
|
||||
var res = User32.MonitorFromWindow(guiInfo.hwndActive, User32.MonitorFlags.MONITOR_DEFAULTTONEAREST);
|
||||
PInvoke.GetGUIThreadInfo(0, ref guiInfo);
|
||||
var res = PInvoke.MonitorFromWindow(guiInfo.hwndActive, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
User32.MONITORINFO monitorInfo = default;
|
||||
MONITORINFO monitorInfo = default;
|
||||
monitorInfo.cbSize = (uint)Marshal.SizeOf(monitorInfo);
|
||||
User32.GetMonitorInfo(res, ref monitorInfo);
|
||||
PInvoke.GetMonitorInfo(res, ref monitorInfo);
|
||||
|
||||
double dpi = User32.GetDpiForWindow(guiInfo.hwndActive) / 96d;
|
||||
|
||||
return (monitorInfo.rcWork.Location, monitorInfo.rcWork.Size, dpi);
|
||||
double dpi = PInvoke.GetDpiForWindow(guiInfo.hwndActive) / 96d;
|
||||
var location = new Point(monitorInfo.rcWork.left, monitorInfo.rcWork.top);
|
||||
return (location, monitorInfo.rcWork.Size, dpi);
|
||||
}
|
||||
|
||||
public static bool IsCapsLockState()
|
||||
{
|
||||
var capital = User32.GetKeyState((int)User32.VK.VK_CAPITAL);
|
||||
var capital = PInvoke.GetKeyState((int)VIRTUAL_KEY.VK_CAPITAL);
|
||||
return capital != 0;
|
||||
}
|
||||
|
||||
public static bool IsShiftState()
|
||||
{
|
||||
var shift = User32.GetKeyState((int)User32.VK.VK_SHIFT);
|
||||
var shift = PInvoke.GetKeyState((int)VIRTUAL_KEY.VK_SHIFT);
|
||||
return shift < 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user