mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
<!-- 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>
86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
// 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.Runtime.InteropServices;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Helpers;
|
|
|
|
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
|
|
{
|
|
internal INPUTTYPE type;
|
|
internal InputUnion data;
|
|
|
|
internal static int Size
|
|
{
|
|
get { return Marshal.SizeOf<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)]
|
|
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,
|
|
}
|
|
}
|