Last active
April 26, 2020 09:10
-
-
Save kusa-mochi/0ef233c5bbed2f28d2e9a91c92501473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// マウスホイールの回転量(マイナスで下回転、プラスで上回転) | |
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