42 lines
1.0 KiB
PowerShell
42 lines
1.0 KiB
PowerShell
param([int]$dx = 1)
|
|
|
|
Add-Type -TypeDefinition @"
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public class MouseInput {
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct MOUSEINPUT {
|
|
public int dx;
|
|
public int dy;
|
|
public uint mouseData;
|
|
public uint dwFlags;
|
|
public uint time;
|
|
public IntPtr dwExtraInfo;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct INPUT {
|
|
public uint type;
|
|
public MOUSEINPUT mi;
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
|
|
|
|
public const uint INPUT_MOUSE = 0;
|
|
public const uint MOUSEEVENTF_MOVE = 0x0001;
|
|
}
|
|
"@
|
|
|
|
$input = New-Object MouseInput+INPUT
|
|
$input.type = [MouseInput]::INPUT_MOUSE
|
|
$input.mi.dx = $dx
|
|
$input.mi.dy = 0
|
|
$input.mi.dwFlags = [MouseInput]::MOUSEEVENTF_MOVE
|
|
$input.mi.time = 0
|
|
$input.mi.dwExtraInfo = [IntPtr]::Zero
|
|
|
|
$size = [Runtime.InteropServices.Marshal]::SizeOf($input)
|
|
[MouseInput]::SendInput(1, @($input), $size) | Out-Null
|