mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
[MouseJump][CQ]Refactor "common" classes into a separate project (#34333)
* [Mouse Jump] - moving common code to MouseJump.Common project - #25482 * [Mouse Jump] - fixing warnings in MouseJump.Common - #25482 * [MouseJump] - cherrypick 5653b4 - Exclude MouseJump Common tests from the checks # Conflicts: # src/modules/MouseUtils/MouseJump.Common.UnitTests/MouseJump.Common.UnitTests.csproj * [mOuSEjUMP] - cherry pick 61aab9 - Fix ci build issues # Conflicts: # src/modules/MouseUtils/MouseJump.Common.UnitTests/MouseJump.Common.UnitTests.csproj * [Mouse Jump] - remove project type guids - #25482 * [Mouse Jump] - simplify mousejump *.csproj files - #25482 * [Mouse Jump] - fixing broken tests - #25482 * [Mouse Jump] - fixing broken build - #25482 * [Mouse Jump] - editing MouseJump.Common.UnitTests.csproj - #25482 * [Mouse Jump] - editing MouseJump.Common.csproj (UseWindowsForms=true) - #25482 * [Mouse Jump] - fixing spellcheck - #25482 * [MouseJump] - enabled implicit usings - #25482 * [Mouse Jump] - re-add csproj attributes - #27511 * ci: Fix signing of Common dll --------- Co-authored-by: Clayton <mike.clayton@delinian.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A Boolean variable (should be TRUE or FALSE).
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef int BOOL;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct BOOL
|
||||
{
|
||||
public readonly int Value;
|
||||
|
||||
public BOOL(int value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public BOOL(bool value)
|
||||
{
|
||||
this.Value = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public static implicit operator bool(BOOL value) => value.Value != 0;
|
||||
|
||||
public static implicit operator BOOL(bool value) => new(value);
|
||||
|
||||
public static implicit operator int(BOOL value) => value.Value;
|
||||
|
||||
public static implicit operator BOOL(int value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The CRECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect
|
||||
/// </remarks>
|
||||
[SuppressMessage("Naming Rules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Name and value taken from Win32Api")]
|
||||
internal readonly struct CRECT
|
||||
{
|
||||
public static readonly CRECT Empty = new(0, 0, 0, 0);
|
||||
|
||||
public readonly LONG left;
|
||||
public readonly LONG top;
|
||||
public readonly LONG right;
|
||||
public readonly LONG bottom;
|
||||
|
||||
public CRECT(
|
||||
int left, int top, int right, int bottom)
|
||||
{
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public CRECT(
|
||||
LONG left, LONG top, LONG right, LONG bottom)
|
||||
{
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(CRECT));
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"left={this.left},top={this.top},right={this.right},bottom={this.bottom}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.
|
||||
/// This type is declared in IntSafe.h as follows:
|
||||
/// typedef unsigned long DWORD;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct DWORD
|
||||
{
|
||||
public readonly uint Value;
|
||||
|
||||
public DWORD(uint value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(DWORD));
|
||||
|
||||
public static implicit operator uint(DWORD value) => value.Value;
|
||||
|
||||
public static implicit operator DWORD(uint value) => new(value);
|
||||
|
||||
public static explicit operator int(DWORD value) => (int)value.Value;
|
||||
|
||||
public static explicit operator DWORD(int value) => new((uint)value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to an object.
|
||||
/// This type is declared in WinNT.h as follows:
|
||||
/// typedef PVOID HANDLE;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct HANDLE
|
||||
{
|
||||
public static readonly HANDLE Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public HANDLE(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == HANDLE.Null.Value;
|
||||
|
||||
public static implicit operator IntPtr(HANDLE value) => value.Value;
|
||||
|
||||
public static explicit operator HANDLE(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to a device context (DC).
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef HANDLE HDC;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct HDC
|
||||
{
|
||||
public static readonly HDC Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public HDC(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == HDC.Null.Value;
|
||||
|
||||
public static implicit operator IntPtr(HDC value) => value.Value;
|
||||
|
||||
public static explicit operator HDC(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to a display monitor.
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// if(WINVER >= 0x0500) typedef HANDLE HMONITOR;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct HMONITOR
|
||||
{
|
||||
public static readonly HMONITOR Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public HMONITOR(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == HMONITOR.Null.Value;
|
||||
|
||||
public static implicit operator int(HMONITOR value) => value.Value.ToInt32();
|
||||
|
||||
public static explicit operator HMONITOR(int value) => new(value);
|
||||
|
||||
public static implicit operator IntPtr(HMONITOR value) => value.Value;
|
||||
|
||||
public static explicit operator HMONITOR(IntPtr value) => new(value);
|
||||
|
||||
public static implicit operator HANDLE(HMONITOR value) => new(value.Value);
|
||||
|
||||
public static explicit operator HMONITOR(HANDLE value) => new(value.Value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to a window.
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef HANDLE HWND;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct HWND
|
||||
{
|
||||
public static readonly HWND Null = new(IntPtr.Zero);
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Name and value taken from Win32Api")]
|
||||
public static readonly HWND HWND_MESSAGE = new(-3);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public HWND(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == HWND.Null.Value;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A 32-bit signed integer.The range is -2147483648 through 2147483647 decimal.
|
||||
/// This type is declared in WinNT.h as follows:
|
||||
/// typedef long LONG;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct LONG
|
||||
{
|
||||
public readonly int Value;
|
||||
|
||||
public LONG(int value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator int(LONG value) => value.Value;
|
||||
|
||||
public static implicit operator LONG(int value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A message parameter.
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef LONG_PTR LPARAM;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct LPARAM
|
||||
{
|
||||
public static readonly LPARAM Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPARAM(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == LPARAM.Null.Value;
|
||||
|
||||
public static implicit operator IntPtr(LPARAM value) => value.Value;
|
||||
|
||||
public static explicit operator LPARAM(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
internal readonly struct LPCRECT
|
||||
{
|
||||
public static readonly LPCRECT Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPCRECT(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public LPCRECT(CRECT value)
|
||||
{
|
||||
this.Value = LPCRECT.ToPtr(value);
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == LPCRECT.Null.Value;
|
||||
|
||||
private static IntPtr ToPtr(CRECT value)
|
||||
{
|
||||
var ptr = Marshal.AllocHGlobal(CRECT.Size);
|
||||
Marshal.StructureToPtr(value, ptr, false);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Value);
|
||||
}
|
||||
|
||||
public static implicit operator IntPtr(LPCRECT value) => value.Value;
|
||||
|
||||
public static explicit operator LPCRECT(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
internal readonly struct LPPOINT
|
||||
{
|
||||
public static readonly LPPOINT Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPPOINT(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public LPPOINT(POINT value)
|
||||
{
|
||||
this.Value = LPPOINT.ToPtr(value);
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == LPPOINT.Null.Value;
|
||||
|
||||
private static IntPtr ToPtr(POINT value)
|
||||
{
|
||||
var ptr = Marshal.AllocHGlobal(POINT.Size);
|
||||
Marshal.StructureToPtr(value, ptr, false);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
public POINT ToStructure()
|
||||
{
|
||||
return Marshal.PtrToStructure<POINT>(this.Value);
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Value);
|
||||
}
|
||||
|
||||
public static implicit operator IntPtr(LPPOINT value) => value.Value;
|
||||
|
||||
public static explicit operator LPPOINT(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
internal readonly struct LPRECT
|
||||
{
|
||||
public static readonly LPRECT Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPRECT(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public LPRECT(RECT value)
|
||||
{
|
||||
this.Value = LPRECT.ToPtr(value);
|
||||
}
|
||||
|
||||
public bool IsNull => this.Value == LPRECT.Null.Value;
|
||||
|
||||
private static IntPtr ToPtr(RECT value)
|
||||
{
|
||||
var ptr = Marshal.AllocHGlobal(RECT.Size);
|
||||
Marshal.StructureToPtr(value, ptr, false);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Value);
|
||||
}
|
||||
|
||||
public static implicit operator IntPtr(LPRECT value) => value.Value;
|
||||
|
||||
public static explicit operator LPRECT(IntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The POINT structure defines the x- and y-coordinates of a point.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Names match Win32 api")]
|
||||
internal readonly struct POINT
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the x-coordinate of the point.
|
||||
/// </summary>
|
||||
public readonly LONG x;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the y-coordinate of the point.
|
||||
/// </summary>
|
||||
public readonly LONG y;
|
||||
|
||||
public POINT(
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public POINT(
|
||||
LONG x,
|
||||
LONG y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(POINT));
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"x={this.x},y={this.y}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The RECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect
|
||||
/// </remarks>
|
||||
[SuppressMessage("Naming Rules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Name and value taken from Win32Api")]
|
||||
internal readonly struct RECT
|
||||
{
|
||||
public static readonly RECT Empty = new(0, 0, 0, 0);
|
||||
|
||||
public readonly LONG left;
|
||||
public readonly LONG top;
|
||||
public readonly LONG right;
|
||||
public readonly LONG bottom;
|
||||
|
||||
public RECT(
|
||||
int left, int top, int right, int bottom)
|
||||
{
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public RECT(
|
||||
LONG left, LONG top, LONG right, LONG bottom)
|
||||
{
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(RECT));
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"left={this.left},top={this.top},right={this.right},bottom={this.bottom}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// An unsigned INT. The range is 0 through 4294967295 decimal.
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef unsigned int UINT;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct UINT
|
||||
{
|
||||
public readonly uint Value;
|
||||
|
||||
public UINT(uint value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator uint(UINT value) => value.Value;
|
||||
|
||||
public static implicit operator UINT(uint value) => new(value);
|
||||
|
||||
public static explicit operator int(UINT value) => (int)value.Value;
|
||||
|
||||
public static explicit operator UINT(int value) => new((uint)value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// An unsigned LONG_PTR.
|
||||
/// This type is declared in BaseTsd.h as follows:
|
||||
/// C++
|
||||
/// #if defined(_WIN64)
|
||||
/// typedef unsigned __int64 ULONG_PTR;
|
||||
/// #else
|
||||
/// typedef unsigned long ULONG_PTR;
|
||||
/// #endif
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct ULONG_PTR
|
||||
{
|
||||
public static readonly ULONG_PTR Null = new(UIntPtr.Zero);
|
||||
|
||||
public readonly UIntPtr Value;
|
||||
|
||||
public ULONG_PTR(UIntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator UIntPtr(ULONG_PTR value) => value.Value;
|
||||
|
||||
public static explicit operator ULONG_PTR(UIntPtr value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A 16-bit unsigned integer.The range is 0 through 65535 decimal.
|
||||
/// This type is declared in WinDef.h as follows:
|
||||
/// typedef unsigned short WORD;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
|
||||
/// </remarks>
|
||||
internal readonly struct WORD
|
||||
{
|
||||
public readonly ushort Value;
|
||||
|
||||
public WORD(ushort value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator ulong(WORD value) => value.Value;
|
||||
|
||||
public static implicit operator WORD(ushort value) => new(value);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Gdi32
|
||||
{
|
||||
/// <summary>
|
||||
/// A raster-operation code. These codes define how the color data for the source
|
||||
/// rectangle is to be combined with the color data for the destination rectangle
|
||||
/// to achieve the final color.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-bitblt
|
||||
/// </remarks>
|
||||
internal enum ROP_CODE : uint
|
||||
{
|
||||
BLACKNESS = 0x00000042,
|
||||
CAPTUREBLT = 0x40000000,
|
||||
DSTINVERT = 0x00550009,
|
||||
MERGECOPY = 0x00C000CA,
|
||||
MERGEPAINT = 0x00BB0226,
|
||||
NOMIRRORBITMAP = 0x80000000,
|
||||
NOTSRCCOPY = 0x00330008,
|
||||
NOTSRCERASE = 0x001100A6,
|
||||
PATCOPY = 0x00F00021,
|
||||
PATINVERT = 0x005A0049,
|
||||
PATPAINT = 0x00FB0A09,
|
||||
SRCAND = 0x008800C6,
|
||||
SRCCOPY = 0x00CC0020,
|
||||
SRCERASE = 0x00440328,
|
||||
SRCINVERT = 0x00660046,
|
||||
SRCPAINT = 0x00EE0086,
|
||||
WHITENESS = 0x00FF0062,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Gdi32
|
||||
{
|
||||
/// <summary>
|
||||
/// The stretching mode.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setstretchbltmode
|
||||
/// </remarks>
|
||||
internal enum STRETCH_BLT_MODE : int
|
||||
{
|
||||
BLACKONWHITE = 1,
|
||||
COLORONCOLOR = 3,
|
||||
HALFTONE = 4,
|
||||
WHITEONBLACK = 2,
|
||||
STRETCH_ANDSCANS = STRETCH_BLT_MODE.BLACKONWHITE,
|
||||
STRETCH_DELETESCANS = STRETCH_BLT_MODE.COLORONCOLOR,
|
||||
STRETCH_HALFTONE = STRETCH_BLT_MODE.HALFTONE,
|
||||
STRETCH_ORSCANS = STRETCH_BLT_MODE.WHITEONBLACK,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Gdi32
|
||||
{
|
||||
/// <summary>
|
||||
/// The SetStretchBltMode function sets the bitmap stretching mode in the specified device context.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is the previous stretching mode.
|
||||
/// If the function fails, the return value is zero.
|
||||
/// This function can return the following value.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setstretchbltmode
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.Gdi32)]
|
||||
internal static partial int SetStretchBltMode(
|
||||
HDC hdc,
|
||||
STRETCH_BLT_MODE mode);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class Gdi32
|
||||
{
|
||||
/// <summary>
|
||||
/// The StretchBlt function copies a bitmap from a source rectangle into a destination
|
||||
/// rectangle, stretching or compressing the bitmap to fit the dimensions of the
|
||||
/// destination rectangle, if necessary. The system stretches or compresses the bitmap
|
||||
/// according to the stretching mode currently set in the destination device context.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchblt
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.Gdi32)]
|
||||
internal static partial BOOL StretchBlt(
|
||||
HDC hdcDest,
|
||||
int xDest,
|
||||
int yDest,
|
||||
int wDest,
|
||||
int hDest,
|
||||
HDC hdcSrc,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
int wSrc,
|
||||
int hSrc,
|
||||
ROP_CODE rop);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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.
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static class Libraries
|
||||
{
|
||||
public const string Gdi32 = "gdi32";
|
||||
public const string User32 = "user32";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The EnumDisplayMonitors function enumerates display monitors (including invisible
|
||||
/// pseudo-monitors associated with the mirroring drivers) that intersect a region formed
|
||||
/// by the intersection of a specified clipping rectangle and the visible region of a
|
||||
/// device context. EnumDisplayMonitors calls an application-defined MonitorEnumProc
|
||||
/// callback function once for each monitor that is enumerated. Note that
|
||||
/// GetSystemMetrics (SM_CMONITORS) counts only the display monitors.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaymonitors
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial BOOL EnumDisplayMonitors(
|
||||
HDC hdc,
|
||||
LPCRECT lprcClip,
|
||||
MONITORENUMPROC lpfnEnum,
|
||||
LPARAM dwData);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The GetMonitorInfo function retrieves information about a display monitor.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is nonzero.
|
||||
/// If the function fails, the return value is zero.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaymonitors
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial BOOL GetMonitorInfoW(
|
||||
HMONITOR hMonitor,
|
||||
LPMONITORINFO lpmi);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The GetWindowDC function retrieves the device context (DC) for the entire window,
|
||||
/// including title bar, menus, and scroll bars. A window device context permits painting
|
||||
/// anywhere in a window, because the origin of the device context is the upper-left
|
||||
/// corner of the window instead of the client area.
|
||||
///
|
||||
/// GetWindowDC assigns default attributes to the window device context each time it
|
||||
/// retrieves the device context. Previous attributes are lost.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is a handle to a device context for the specified window.
|
||||
/// If the function fails, the return value is NULL, indicating an error or an invalid hWnd parameter.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowdc
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial HDC GetWindowDC(
|
||||
HWND hWnd);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
|
||||
/// </remarks>
|
||||
internal readonly struct LPMONITORINFO
|
||||
{
|
||||
public static readonly LPMONITORINFO Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPMONITORINFO(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public LPMONITORINFO(MONITORINFO value)
|
||||
{
|
||||
this.Value = LPMONITORINFO.ToPtr(value);
|
||||
}
|
||||
|
||||
public MONITORINFO ToStructure()
|
||||
{
|
||||
return Marshal.PtrToStructure<MONITORINFO>(this.Value);
|
||||
}
|
||||
|
||||
private static IntPtr ToPtr(MONITORINFO value)
|
||||
{
|
||||
var ptr = Marshal.AllocHGlobal(MONITORINFO.Size);
|
||||
Marshal.StructureToPtr(value, ptr, false);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Value);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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 static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// A MonitorEnumProc function is an application-defined callback function that is called by the EnumDisplayMonitors function.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nc-winuser-monitorenumproc
|
||||
/// </remarks>
|
||||
internal delegate BOOL MONITORENUMPROC(
|
||||
HMONITOR unnamedParam1,
|
||||
HDC unnamedParam2,
|
||||
LPRECT unnamedParam3,
|
||||
LPARAM unnamedParam4);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-monitorinfo
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Parameter name matches Win32 api")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly struct MONITORINFO
|
||||
{
|
||||
public readonly DWORD cbSize;
|
||||
public readonly RECT rcMonitor;
|
||||
public readonly RECT rcWork;
|
||||
public readonly MONITOR_INFO_FLAGS dwFlags;
|
||||
|
||||
public MONITORINFO(DWORD cbSize, RECT rcMonitor, RECT rcWork, MONITOR_INFO_FLAGS dwFlags)
|
||||
{
|
||||
this.cbSize = cbSize;
|
||||
this.rcMonitor = rcMonitor;
|
||||
this.rcWork = rcWork;
|
||||
this.dwFlags = dwFlags;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(MONITORINFO));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
[SuppressMessage("SA1310", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Names match Win32 api")]
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines the function's return value if the point is not contained within any display monitor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfrompoint
|
||||
/// </remarks>
|
||||
internal enum MONITOR_FROM_FLAGS : uint
|
||||
{
|
||||
MONITOR_DEFAULTTONULL = 0x00000000,
|
||||
MONITOR_DEFAULTTOPRIMARY = 0x00000001,
|
||||
MONITOR_DEFAULTTONEAREST = 0x00000002,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
[SuppressMessage("SA1310", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Names match Win32 api")]
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of flags that represent attributes of the display monitor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-monitorinfo
|
||||
/// </remarks>
|
||||
internal enum MONITOR_INFO_FLAGS : uint
|
||||
{
|
||||
MONITORINFOF_PRIMARY = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The MonitorFromPoint function retrieves a handle to the display monitor that contains a specified point.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the point is contained by a display monitor, the return value is an HMONITOR handle to that display monitor.
|
||||
/// If the point is not contained by a display monitor, the return value depends on the value of dwFlags.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfrompoint
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial HMONITOR MonitorFromPoint(
|
||||
POINT pt,
|
||||
MONITOR_FROM_FLAGS dwFlags);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The ReleaseDC function releases a device context (DC), freeing it for use by other
|
||||
/// applications. The effect of the ReleaseDC function depends on the type of DC. It
|
||||
/// frees only common and window DCs. It has no effect on class or private DCs.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The return value indicates whether the DC was released. If the DC was released, the return value is 1.
|
||||
/// If the DC was not released, the return value is zero.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-releasedc
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial int ReleaseDC(
|
||||
HWND hWnd,
|
||||
HDC hDC);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a simulated message generated by an input device
|
||||
/// other than a keyboard or mouse.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-hardwareinput
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Parameter name matches Win32 api")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly struct HARDWAREINPUT
|
||||
{
|
||||
public readonly DWORD uMsg;
|
||||
public readonly WORD wParamL;
|
||||
public readonly WORD wParamH;
|
||||
|
||||
public HARDWAREINPUT(
|
||||
DWORD uMsg,
|
||||
WORD wParamL,
|
||||
WORD wParamH)
|
||||
{
|
||||
this.uMsg = uMsg;
|
||||
this.wParamL = wParamL;
|
||||
this.wParamH = wParamH;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-input
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Parameter name matches Win32 api")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly struct INPUT
|
||||
{
|
||||
public readonly INPUT_TYPE type;
|
||||
public readonly DUMMYUNIONNAME data;
|
||||
|
||||
public INPUT(INPUT_TYPE type, DUMMYUNIONNAME data)
|
||||
{
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static int Size =>
|
||||
Marshal.SizeOf(typeof(INPUT));
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public readonly struct DUMMYUNIONNAME
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public readonly MOUSEINPUT mi;
|
||||
[FieldOffset(0)]
|
||||
public readonly KEYBDINPUT ki;
|
||||
[FieldOffset(0)]
|
||||
public readonly HARDWAREINPUT hi;
|
||||
|
||||
public DUMMYUNIONNAME(MOUSEINPUT mi)
|
||||
{
|
||||
this.mi = mi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
[SuppressMessage("SA1310", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Names match Win32 api")]
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of the input event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-input
|
||||
/// </remarks>
|
||||
internal enum INPUT_TYPE : uint
|
||||
{
|
||||
INPUT_MOUSE = 0,
|
||||
INPUT_KEYBOARD = 1,
|
||||
INPUT_HARDWARE = 2,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a simulated keyboard event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-keybdinput
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Parameter name matches Win32 api")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly struct KEYBDINPUT
|
||||
{
|
||||
public readonly WORD wVk;
|
||||
public readonly WORD wScan;
|
||||
public readonly DWORD dwFlags;
|
||||
public readonly DWORD time;
|
||||
public readonly ULONG_PTR dwExtraInfo;
|
||||
|
||||
public KEYBDINPUT(
|
||||
WORD wVk,
|
||||
WORD wScan,
|
||||
DWORD dwFlags,
|
||||
DWORD time,
|
||||
ULONG_PTR dwExtraInfo)
|
||||
{
|
||||
this.wVk = wVk;
|
||||
this.wScan = wScan;
|
||||
this.dwFlags = dwFlags;
|
||||
this.time = time;
|
||||
this.dwExtraInfo = dwExtraInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
|
||||
/// </remarks>
|
||||
internal readonly struct LPINPUT
|
||||
{
|
||||
public static readonly LPINPUT Null = new(IntPtr.Zero);
|
||||
|
||||
public readonly IntPtr Value;
|
||||
|
||||
public LPINPUT(IntPtr value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
public LPINPUT(INPUT[] values)
|
||||
{
|
||||
this.Value = LPINPUT.ToPtr(values);
|
||||
}
|
||||
|
||||
public INPUT ToStructure()
|
||||
{
|
||||
return Marshal.PtrToStructure<INPUT>(this.Value);
|
||||
}
|
||||
|
||||
public IEnumerable<INPUT> ToStructure(int count)
|
||||
{
|
||||
var ptr = this.Value;
|
||||
var size = INPUT.Size;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
yield return Marshal.PtrToStructure<INPUT>(this.Value);
|
||||
ptr += size;
|
||||
}
|
||||
}
|
||||
|
||||
private static IntPtr ToPtr(INPUT[] values)
|
||||
{
|
||||
var mem = Marshal.AllocHGlobal(INPUT.Size * values.Length);
|
||||
var ptr = mem;
|
||||
var size = INPUT.Size;
|
||||
foreach (var value in values)
|
||||
{
|
||||
Marshal.StructureToPtr(value, ptr, false);
|
||||
ptr += size;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
Marshal.FreeHGlobal(this.Value);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.GetType().Name}({this.Value})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a simulated mouse event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-mouseinput
|
||||
/// </remarks>
|
||||
[SuppressMessage("SA1307", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Parameter name matches Win32 api")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal readonly struct MOUSEINPUT
|
||||
{
|
||||
public readonly int dx;
|
||||
public readonly int dy;
|
||||
public readonly DWORD mouseData;
|
||||
public readonly MOUSE_EVENT_FLAGS dwFlags;
|
||||
public readonly DWORD time;
|
||||
public readonly ULONG_PTR dwExtraInfo;
|
||||
|
||||
public MOUSEINPUT(
|
||||
int dx,
|
||||
int dy,
|
||||
DWORD mouseData,
|
||||
MOUSE_EVENT_FLAGS dwFlags,
|
||||
DWORD time,
|
||||
ULONG_PTR dwExtraInfo)
|
||||
{
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.mouseData = mouseData;
|
||||
this.dwFlags = dwFlags;
|
||||
this.time = time;
|
||||
this.dwExtraInfo = dwExtraInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
[SuppressMessage("SA1310", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Names match Win32 api")]
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-mouseinput
|
||||
/// </remarks>
|
||||
[Flags]
|
||||
internal enum MOUSE_EVENT_FLAGS : uint
|
||||
{
|
||||
MOUSEEVENTF_MOVE = 0x0001,
|
||||
MOUSEEVENTF_LEFTDOWN = 0x0002,
|
||||
MOUSEEVENTF_LEFTUP = 0x0004,
|
||||
MOUSEEVENTF_RIGHTDOWN = 0x0008,
|
||||
MOUSEEVENTF_RIGHTUP = 0x0010,
|
||||
MOUSEEVENTF_MIDDLEDOWN = 0x0020,
|
||||
MOUSEEVENTF_MIDDLEUP = 0x0040,
|
||||
MOUSEEVENTF_XDOWN = 0x0080,
|
||||
MOUSEEVENTF_XUP = 0x0100,
|
||||
MOUSEEVENTF_WHEEL = 0x0800,
|
||||
MOUSEEVENTF_HWHEEL = 0x1000,
|
||||
MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000,
|
||||
MOUSEEVENTF_VIRTUALDESK = 0x4000,
|
||||
MOUSEEVENTF_ABSOLUTE = 0x8000,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Synthesizes keystrokes, mouse motions, and button clicks.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The function returns the number of events that it successfully inserted into the keyboard or mouse input stream.
|
||||
/// If the function returns zero, the input was already blocked by another thread.
|
||||
/// To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32, SetLastError = true)]
|
||||
internal static partial UINT SendInput(
|
||||
UINT cInputs,
|
||||
LPINPUT pInputs,
|
||||
int cbSize);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the position of the mouse cursor, in screen coordinates.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns nonzero if successful or zero otherwise.
|
||||
/// To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcursorpos
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32, SetLastError = true)]
|
||||
internal static partial BOOL GetCursorPos(
|
||||
LPPOINT lpPoint);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a handle to the desktop window. The desktop window covers the entire
|
||||
/// screen. The desktop window is the area on top of which other windows are painted.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The return value is a handle to the desktop window.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdesktopwindow
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial HWND GetDesktopWindow();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the specified system metric or system configuration setting.
|
||||
///
|
||||
/// Note that all dimensions retrieved by GetSystemMetrics are in pixels.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If the function succeeds, the return value is the requested system metric or configuration setting.
|
||||
/// If the function fails, the return value is 0. GetLastError does not provide extended error information.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32)]
|
||||
internal static partial int GetSystemMetrics(
|
||||
SYSTEM_METRICS_INDEX smIndex);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
[SuppressMessage("SA1310", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Names match Win32 api")]
|
||||
internal static partial class User32
|
||||
{
|
||||
internal enum SYSTEM_METRICS_INDEX : uint
|
||||
{
|
||||
SM_ARRANGE = 56,
|
||||
SM_CLEANBOOT = 67,
|
||||
SM_CMONITORS = 80,
|
||||
SM_CMOUSEBUTTONS = 43,
|
||||
SM_CONVERTIBLESLATEMODE = 0x2003,
|
||||
SM_CXBORDER = 5,
|
||||
SM_CXCURSOR = 13,
|
||||
SM_CXDLGFRAME = 7,
|
||||
SM_CXDOUBLECLK = 36,
|
||||
SM_CXDRAG = 68,
|
||||
SM_CXEDGE = 45,
|
||||
SM_CXFIXEDFRAME = SM_CXDLGFRAME,
|
||||
SM_CXFOCUSBORDER = 83,
|
||||
SM_CXFRAME = 32,
|
||||
SM_CXFULLSCREEN = 16,
|
||||
SM_CXHSCROLL = 21,
|
||||
SM_CXHTHUMB = 10,
|
||||
SM_CXICON = 11,
|
||||
SM_CXICONSPACING = 38,
|
||||
SM_CXMAXIMIZED = 61,
|
||||
SM_CXMAXTRACK = 59,
|
||||
SM_CXMENUCHECK = 71,
|
||||
SM_CXMENUSIZE = 54,
|
||||
SM_CXMIN = 28,
|
||||
SM_CXMINIMIZED = 57,
|
||||
SM_CXMINSPACING = 47,
|
||||
SM_CXMINTRACK = 34,
|
||||
SM_CXPADDEDBORDER = 92,
|
||||
SM_CXSCREEN = 0,
|
||||
SM_CXSIZE = 30,
|
||||
SM_CXSIZEFRAME = SM_CXFRAME,
|
||||
SM_CXSMICON = 49,
|
||||
SM_CXSMSIZE = 52,
|
||||
SM_CXVIRTUALSCREEN = 78,
|
||||
SM_CXVSCROLL = 2,
|
||||
SM_CYBORDER = 6,
|
||||
SM_CYCAPTION = 4,
|
||||
SM_CYCURSOR = 14,
|
||||
SM_CYDLGFRAME = 8,
|
||||
SM_CYDOUBLECLK = 37,
|
||||
SM_CYDRAG = 69,
|
||||
SM_CYEDGE = 46,
|
||||
SM_CYFIXEDFRAME = SM_CYDLGFRAME,
|
||||
SM_CYFOCUSBORDER = 84,
|
||||
SM_CYFRAME = 33,
|
||||
SM_CYFULLSCREEN = 17,
|
||||
SM_CYHSCROLL = 3,
|
||||
SM_CYICON = 12,
|
||||
SM_CYICONSPACING = 39,
|
||||
SM_CYKANJIWINDOW = 18,
|
||||
SM_CYMAXIMIZED = 62,
|
||||
SM_CYMAXTRACK = 60,
|
||||
SM_CYMENU = 15,
|
||||
SM_CYMENUCHECK = 72,
|
||||
SM_CYMENUSIZE = 55,
|
||||
SM_CYMIN = 29,
|
||||
SM_CYMINIMIZED = 58,
|
||||
SM_CYMINSPACING = 48,
|
||||
SM_CYMINTRACK = 35,
|
||||
SM_CYSCREEN = 1,
|
||||
SM_CYSIZE = 31,
|
||||
SM_CYSIZEFRAME = SM_CYFRAME,
|
||||
SM_CYSMCAPTION = 51,
|
||||
SM_CYSMICON = 50,
|
||||
SM_CYSMSIZE = 53,
|
||||
SM_CYVIRTUALSCREEN = 79,
|
||||
SM_CYVSCROLL = 20,
|
||||
SM_CYVTHUMB = 9,
|
||||
SM_DBCSENABLED = 42,
|
||||
SM_DEBUG = 22,
|
||||
SM_DIGITIZER = 94,
|
||||
SM_IMMENABLED = 82,
|
||||
SM_MAXIMUMTOUCHES = 95,
|
||||
SM_MEDIACENTER = 87,
|
||||
SM_MENUDROPALIGNMENT = 40,
|
||||
SM_MIDEASTENABLED = 74,
|
||||
SM_MOUSEPRESENT = 19,
|
||||
SM_MOUSEHORIZONTALWHEELPRESENT = 91,
|
||||
SM_MOUSEWHEELPRESENT = 75,
|
||||
SM_NETWORK = 63,
|
||||
SM_PENWINDOWS = 41,
|
||||
SM_REMOTECONTROL = 0x2001,
|
||||
SM_REMOTESESSION = 0x1000,
|
||||
SM_SAMEDISPLAYFORMA = 81,
|
||||
SM_SECURE = 44,
|
||||
SM_SERVERR2 = 89,
|
||||
SM_SHOWSOUNDS = 70,
|
||||
SM_SHUTTINGDOWN = 0x2000,
|
||||
SM_SLOWMACHINE = 73,
|
||||
SM_STARTER = 88,
|
||||
SM_SWAPBUTTON = 23,
|
||||
SM_SYSTEMDOCKED = 0x2004,
|
||||
SM_TABLETPC = 86,
|
||||
SM_XVIRTUALSCREEN = 76,
|
||||
SM_YVIRTUALSCREEN = 77,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.Runtime.InteropServices;
|
||||
|
||||
using static MouseJump.Common.NativeMethods.Core;
|
||||
|
||||
namespace MouseJump.Common.NativeMethods;
|
||||
|
||||
internal static partial class User32
|
||||
{
|
||||
/// <summary>
|
||||
/// Moves the cursor to the specified screen coordinates. If the new coordinates are not within
|
||||
/// the screen rectangle set by the most recent ClipCursor function call, the system automatically
|
||||
/// adjusts the coordinates so that the cursor stays within the rectangle.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns nonzero if successful or zero otherwise.
|
||||
/// To get extended error information, call GetLastError.
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getcursorpos
|
||||
/// </remarks>
|
||||
[LibraryImport(Libraries.User32, SetLastError = true)]
|
||||
internal static partial BOOL SetCursorPos(
|
||||
int X,
|
||||
int Y);
|
||||
}
|
||||
Reference in New Issue
Block a user