简体   繁体   中英

c# simulate mouse wheel down

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM