diff --git a/Directory.Packages.props b/Directory.Packages.props index 5e65a85612..bbf98c9616 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,4 +1,4 @@ - + true @@ -17,10 +17,8 @@ - - @@ -28,7 +26,6 @@ - @@ -43,7 +40,6 @@ - @@ -51,7 +47,6 @@ - @@ -86,8 +81,6 @@ - - diff --git a/NOTICE.md b/NOTICE.md index 172af41a0b..b682ec1df4 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -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 diff --git a/src/modules/MouseWithoutBorders/App/MouseWithoutBorders.csproj b/src/modules/MouseWithoutBorders/App/MouseWithoutBorders.csproj index 9f7fa4502d..8ea99c20a2 100644 --- a/src/modules/MouseWithoutBorders/App/MouseWithoutBorders.csproj +++ b/src/modules/MouseWithoutBorders/App/MouseWithoutBorders.csproj @@ -215,7 +215,6 @@ - diff --git a/src/modules/poweraccent/PowerAccent.Core/Models/Point.cs b/src/modules/poweraccent/PowerAccent.Core/Models/Point.cs index 485cdff533..d58d305a2f 100644 --- a/src/modules/poweraccent/PowerAccent.Core/Models/Point.cs +++ b/src/modules/poweraccent/PowerAccent.Core/Models/Point.cs @@ -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) { diff --git a/src/modules/poweraccent/PowerAccent.Core/NativeMethods.txt b/src/modules/poweraccent/PowerAccent.Core/NativeMethods.txt new file mode 100644 index 0000000000..6aeae331c3 --- /dev/null +++ b/src/modules/poweraccent/PowerAccent.Core/NativeMethods.txt @@ -0,0 +1,6 @@ +GetDpiForWindow +GetGUIThreadInfo +GetKeyState +GetMonitorInfo +MonitorFromWindow +SendInput \ No newline at end of file diff --git a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.Core.csproj b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.Core.csproj index 785ba62a4f..c20e479b93 100644 --- a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.Core.csproj +++ b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.Core.csproj @@ -23,11 +23,13 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - diff --git a/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs b/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs index e5802565e0..53f884b0d1 100644 --- a/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs +++ b/src/modules/poweraccent/PowerAccent.Core/Tools/WindowsFunctions.cs @@ -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()); + 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()); } } } - 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; } }