mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
[cmdpal][AOT] fix some cmdpal aot issue (#40301)
<!-- 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 <del>Most of them are safe change but only one line may break something is in [TrayIconService.cs](https://github.com/microsoft/PowerToys/compare/yuleng/aot/pr?expand=1#diff-bc3e603a50df89710c69ff6f4fc8f29967fca19cdbe615f06b53534e9c986bb5)</del> ok, I've confirmed no problem. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] **Closes:** #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **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 Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
@@ -121,7 +121,7 @@ public class ExtensionWrapper : IExtensionWrapper
|
|||||||
|
|
||||||
if (hr.Value == -2147024893)
|
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 don't really need to throw this exception.
|
||||||
// We'll just return out nothing.
|
// We'll just return out nothing.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public delegate bool IsActive();
|
|||||||
|
|
||||||
public delegate bool FilterAccessibleKeyboardEvents(int key, UIntPtr extraInfo);
|
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 WmKeyDown = 0x100;
|
||||||
private const int WmKeyUp = 0x101;
|
private const int WmKeyUp = 0x101;
|
||||||
|
|||||||
@@ -5,82 +5,81 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
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)]
|
internal INPUTTYPE type;
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:Accessible fields should begin with upper-case letter", Justification = "Matching Native Structure")]
|
internal InputUnion data;
|
||||||
internal struct INPUT
|
|
||||||
{
|
|
||||||
internal INPUTTYPE type;
|
|
||||||
internal InputUnion data;
|
|
||||||
|
|
||||||
internal static int Size
|
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
|
|
||||||
{
|
{
|
||||||
[FieldOffset(0)]
|
get { return Marshal.SizeOf<INPUT>(); }
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Helpers;
|
namespace Microsoft.PowerToys.Settings.UI.Helpers;
|
||||||
|
|
||||||
public static class NativeMethods
|
public static partial class NativeMethods
|
||||||
{
|
{
|
||||||
private const int WS_POPUP = 1 << 31; // 0x80000000
|
private const int WS_POPUP = 1 << 31; // 0x80000000
|
||||||
internal const int GWL_STYLE = -16;
|
internal const int GWL_STYLE = -16;
|
||||||
@@ -26,11 +26,11 @@ public static class NativeMethods
|
|||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
|
internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[LibraryImport("user32.dll")]
|
||||||
internal static extern uint SendInput(uint nInputs, NativeKeyboardHelper.INPUT[] pInputs, int cbSize);
|
internal static partial uint SendInput(uint nInputs, NativeKeyboardHelper.INPUT[] pInputs, int cbSize);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
[LibraryImport("user32.dll")]
|
||||||
internal static extern short GetAsyncKeyState(int vKey);
|
internal static partial short GetAsyncKeyState(int vKey);
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ internal sealed partial class TrayIconService
|
|||||||
_largeIcon = GetAppIconHandle();
|
_largeIcon = GetAppIconHandle();
|
||||||
_trayIconData = new NOTIFYICONDATAW()
|
_trayIconData = new NOTIFYICONDATAW()
|
||||||
{
|
{
|
||||||
cbSize = (uint)Marshal.SizeOf(typeof(NOTIFYICONDATAW)),
|
cbSize = (uint)Marshal.SizeOf<NOTIFYICONDATAW>(),
|
||||||
hWnd = _hwnd,
|
hWnd = _hwnd,
|
||||||
uID = MY_NOTIFY_ID,
|
uID = MY_NOTIFY_ID,
|
||||||
uFlags = NOTIFY_ICON_DATA_FLAGS.NIF_MESSAGE | NOTIFY_ICON_DATA_FLAGS.NIF_ICON | NOTIFY_ICON_DATA_FLAGS.NIF_TIP,
|
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()
|
private DestroyIconSafeHandle GetAppIconHandle()
|
||||||
{
|
{
|
||||||
var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
var exePath = Path.Combine(AppContext.BaseDirectory, "Microsoft.CmdPal.UI.exe");
|
||||||
DestroyIconSafeHandle largeIcon;
|
DestroyIconSafeHandle largeIcon;
|
||||||
PInvoke.ExtractIconEx(exePath, 0, out largeIcon, out _, 1);
|
PInvoke.ExtractIconEx(exePath, 0, out largeIcon, out _, 1);
|
||||||
return largeIcon;
|
return largeIcon;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
GetPhysicallyInstalledSystemMemory
|
GetPhysicallyInstalledSystemMemory
|
||||||
GlobalMemoryStatusEx
|
GlobalMemoryStatusEx
|
||||||
GetSystemInfo
|
GetSystemInfo
|
||||||
CoCreateInstance
|
|
||||||
GetForegroundWindow
|
GetForegroundWindow
|
||||||
SetForegroundWindow
|
SetForegroundWindow
|
||||||
GetWindowRect
|
GetWindowRect
|
||||||
@@ -21,10 +20,7 @@ SetActiveWindow
|
|||||||
MonitorFromWindow
|
MonitorFromWindow
|
||||||
GetMonitorInfo
|
GetMonitorInfo
|
||||||
GetDpiForMonitor
|
GetDpiForMonitor
|
||||||
SHCreateStreamOnFileEx
|
|
||||||
CoAllowSetForegroundWindow
|
CoAllowSetForegroundWindow
|
||||||
SHCreateStreamOnFileEx
|
|
||||||
SHLoadIndirectString
|
|
||||||
WM_HOTKEY
|
WM_HOTKEY
|
||||||
WM_NCLBUTTONDBLCLK
|
WM_NCLBUTTONDBLCLK
|
||||||
|
|
||||||
@@ -33,7 +29,6 @@ LoadIcon
|
|||||||
WM_USER
|
WM_USER
|
||||||
WM_WINDOWPOSCHANGING
|
WM_WINDOWPOSCHANGING
|
||||||
RegisterWindowMessageW
|
RegisterWindowMessageW
|
||||||
GetModuleHandleW
|
|
||||||
ExtractIconEx
|
ExtractIconEx
|
||||||
TRACK_POPUP_MENU_FLAGS
|
TRACK_POPUP_MENU_FLAGS
|
||||||
WM_COMMAND
|
WM_COMMAND
|
||||||
|
|||||||
Reference in New Issue
Block a user