Closed aspmaker closed 1 year ago
I think for windows we can use SendInput
method from user32.dll.
here is the nursery code
[DllImport("user32.dll", SetLastError = true)]
private static extern uint SendInput(uint inputCount, Input[] input, int size);
public void MouseScrollUpDown(int moveTo)
{
var input = new Input
{
Type = InputType.Mouse,
MouseInputWithUnion = new MouseInput(moveTo, MouseState.MouseWheelUpDown)
};
if (SendInput(1, new Input[] { input }, Marshal.SizeOf(input)) == 0)
throw new Exception();
}
public void MouseScrollLeftRight(int moveTo)
{
var input = new Input
{
Type = InputType.Mouse,
MouseInputWithUnion = new MouseInput(moveTo, MouseState.MouseWheelLeftRight)
};
if (SendInput(1, new Input[] { input }, Marshal.SizeOf(input)) == 0)
throw new Exception();
}
we can also make mouse scroll. in linux we can use button 4 and button 5 4 for scroll up 5 for scroll down but i don't know about mac.
Hello, can we simulate the mouse whell scroll? Thank you.
in java.awt.Robot mouseWheel
public void mouseWheel(int wheelAmt) Rotates the scroll wheel on wheel-equipped mice.
Parameters: wheelAmt - number of "notches" to move the mouse wheel Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user. Since: 1.4