diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
index 2a6d7c65c1..5b4eee44ef 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
@@ -121,7 +121,7 @@ public class ExtensionWrapper : IExtensionWrapper
if (hr.Value == -2147024893)
{
- Logger.LogDebug($"Failed to find {ExtensionDisplayName}: {hr}. It may have been uninstalled or deleted.");
+ Logger.LogError($"Failed to find {ExtensionDisplayName}: {hr}. It may have been uninstalled or deleted.");
// We don't really need to throw this exception.
// We'll just return out nothing.
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
index 66f482f502..6ea1c708a7 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/HotkeySettingsControlHook.cs
@@ -12,7 +12,7 @@ public delegate bool IsActive();
public delegate bool FilterAccessibleKeyboardEvents(int key, UIntPtr extraInfo);
-public class HotkeySettingsControlHook : IDisposable
+public partial class HotkeySettingsControlHook : IDisposable
{
private const int WmKeyDown = 0x100;
private const int WmKeyUp = 0x101;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
index 9d3961f907..48b02c4412 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeKeyboardHelper.cs
@@ -5,82 +5,81 @@
using System;
using System.Runtime.InteropServices;
-namespace Microsoft.PowerToys.Settings.UI.Helpers
+namespace Microsoft.PowerToys.Settings.UI.Helpers;
+
+internal static class NativeKeyboardHelper
{
- internal static class NativeKeyboardHelper
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct INPUT
{
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct INPUT
- {
- internal INPUTTYPE type;
- internal InputUnion data;
+ internal INPUTTYPE type;
+ internal InputUnion data;
- internal static int Size
- {
- get { return Marshal.SizeOf(typeof(INPUT)); }
- }
- }
-
- [StructLayout(LayoutKind.Explicit)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct InputUnion
+ internal static int Size
{
- [FieldOffset(0)]
- internal MOUSEINPUT mi;
- [FieldOffset(0)]
- internal KEYBDINPUT ki;
- [FieldOffset(0)]
- internal HARDWAREINPUT hi;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct MOUSEINPUT
- {
- internal int dx;
- internal int dy;
- internal int mouseData;
- internal uint dwFlags;
- internal uint time;
- internal UIntPtr dwExtraInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct KEYBDINPUT
- {
- internal short wVk;
- internal short wScan;
- internal uint dwFlags;
- internal int time;
- internal UIntPtr dwExtraInfo;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
- internal struct HARDWAREINPUT
- {
- internal int uMsg;
- internal short wParamL;
- internal short wParamH;
- }
-
- internal enum INPUTTYPE : uint
- {
- INPUT_MOUSE = 0,
- INPUT_KEYBOARD = 1,
- INPUT_HARDWARE = 2,
- }
-
- [Flags]
- internal enum KeyEventF
- {
- KeyDown = 0x0000,
- ExtendedKey = 0x0001,
- KeyUp = 0x0002,
- Unicode = 0x0004,
- Scancode = 0x0008,
+ get { return Marshal.SizeOf(); }
}
}
+
+ [StructLayout(LayoutKind.Explicit)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct InputUnion
+ {
+ [FieldOffset(0)]
+ internal MOUSEINPUT mi;
+ [FieldOffset(0)]
+ internal KEYBDINPUT ki;
+ [FieldOffset(0)]
+ internal HARDWAREINPUT hi;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct MOUSEINPUT
+ {
+ internal int dx;
+ internal int dy;
+ internal int mouseData;
+ internal uint dwFlags;
+ internal uint time;
+ internal UIntPtr dwExtraInfo;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct KEYBDINPUT
+ {
+ internal short wVk;
+ internal short wScan;
+ internal uint dwFlags;
+ internal int time;
+ internal UIntPtr dwExtraInfo;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
+ internal struct HARDWAREINPUT
+ {
+ internal int uMsg;
+ internal short wParamL;
+ internal short wParamH;
+ }
+
+ internal enum INPUTTYPE : uint
+ {
+ INPUT_MOUSE = 0,
+ INPUT_KEYBOARD = 1,
+ INPUT_HARDWARE = 2,
+ }
+
+ [Flags]
+ internal enum KeyEventF
+ {
+ KeyDown = 0x0000,
+ ExtendedKey = 0x0001,
+ KeyUp = 0x0002,
+ Unicode = 0x0004,
+ Scancode = 0x0008,
+ }
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeMethods.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeMethods.cs
index f89b11391b..38a50a0b94 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeMethods.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/ShortcutControl/NativeMethods.cs
@@ -7,7 +7,7 @@ using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Helpers;
-public static class NativeMethods
+public static partial class NativeMethods
{
private const int WS_POPUP = 1 << 31; // 0x80000000
internal const int GWL_STYLE = -16;
@@ -26,11 +26,11 @@ public static class NativeMethods
[DllImport("user32.dll")]
internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
- [DllImport("user32.dll")]
- internal static extern uint SendInput(uint nInputs, NativeKeyboardHelper.INPUT[] pInputs, int cbSize);
+ [LibraryImport("user32.dll")]
+ internal static partial uint SendInput(uint nInputs, NativeKeyboardHelper.INPUT[] pInputs, int cbSize);
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
- internal static extern short GetAsyncKeyState(int vKey);
+ [LibraryImport("user32.dll")]
+ internal static partial short GetAsyncKeyState(int vKey);
[DllImport("user32.dll", SetLastError = true)]
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
index 3aae253512..df72b56ef7 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/TrayIconService.cs
@@ -72,7 +72,7 @@ internal sealed partial class TrayIconService
_largeIcon = GetAppIconHandle();
_trayIconData = new NOTIFYICONDATAW()
{
- cbSize = (uint)Marshal.SizeOf(typeof(NOTIFYICONDATAW)),
+ cbSize = (uint)Marshal.SizeOf(),
hWnd = _hwnd,
uID = MY_NOTIFY_ID,
uFlags = NOTIFY_ICON_DATA_FLAGS.NIF_MESSAGE | NOTIFY_ICON_DATA_FLAGS.NIF_ICON | NOTIFY_ICON_DATA_FLAGS.NIF_TIP,
@@ -133,7 +133,7 @@ internal sealed partial class TrayIconService
private DestroyIconSafeHandle GetAppIconHandle()
{
- var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
+ var exePath = Path.Combine(AppContext.BaseDirectory, "Microsoft.CmdPal.UI.exe");
DestroyIconSafeHandle largeIcon;
PInvoke.ExtractIconEx(exePath, 0, out largeIcon, out _, 1);
return largeIcon;
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
index 427742f95f..35fafb4680 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt
@@ -1,7 +1,6 @@
GetPhysicallyInstalledSystemMemory
GlobalMemoryStatusEx
GetSystemInfo
-CoCreateInstance
GetForegroundWindow
SetForegroundWindow
GetWindowRect
@@ -21,10 +20,7 @@ SetActiveWindow
MonitorFromWindow
GetMonitorInfo
GetDpiForMonitor
-SHCreateStreamOnFileEx
CoAllowSetForegroundWindow
-SHCreateStreamOnFileEx
-SHLoadIndirectString
WM_HOTKEY
WM_NCLBUTTONDBLCLK
@@ -33,7 +29,6 @@ LoadIcon
WM_USER
WM_WINDOWPOSCHANGING
RegisterWindowMessageW
-GetModuleHandleW
ExtractIconEx
TRACK_POPUP_MENU_FLAGS
WM_COMMAND