Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# simulate mouse wheel down

Tags:

c#

.net

I use the following code:

private const int MOUSEEVENTF_WHEEL = 0x0800;

public void MouseWheelUp()
{
    mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 120, 0);
}

But how do I make it work for scrolling down?

like image 901
Яктенс Тид Avatar asked May 16 '16 20:05

Яктенс Тид


1 Answers

mouse_event function

function signature:

VOID WINAPI mouse_event(
  _In_ DWORD     dwFlags,
  _In_ DWORD     dx,
  _In_ DWORD     dy,
  _In_ DWORD     dwData,
  _In_ ULONG_PTR dwExtraInfo
);

If dwFlags contains MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.

To scroll down :

mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120, 0);
like image 162
Xiaoy312 Avatar answered Sep 25 '22 19:09

Xiaoy312