Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Last active April 26, 2020 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusa-mochi/0ef233c5bbed2f28d2e9a91c92501473 to your computer and use it in GitHub Desktop.
Save kusa-mochi/0ef233c5bbed2f28d2e9a91c92501473 to your computer and use it in GitHub Desktop.
// マウスホイールの回転量(マイナスで下回転、プラスで上回転)
int amount = -3; // 下に3段階回転させる。
// マウスポインタの左右位置(左端が0)
int x = 100;
// マウスポインタの上下位置(上端が0)
int y = 200;
INPUT input = new INPUT
{
type = NativeMethods.INPUT_MOUSE,
ui = new INPUT_UNION
{
mouse = new MOUSEINPUT
{
dwFlags = NativeMethods.MOUSEEVENTF_WHEEL,
dx = x,
dy = y,
mouseData = amount * 120, // もっと細かく制御したい場合は、ここでより細かな単位で整数を指定してあげればよい。
dwExtraInfo = IntPtr.Zero,
time = 0
}
}
};
NativeMethods.SendInput(1, ref input, Marshal.SizeOf(input));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment