Reputation: 401
Whatever positive value is in place of 100(dwData), scrolling up takes place instead of scrolling down. Negative value shows up error. The D7 help (I'm on XE2 though) says something about a negative value and NT. If such a function is too old for XP, please suggest some alternative solution.
procedure TMainform.tmr1Timer(Sender: TObject);
begin
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 100, 0);
end;
Upvotes: 3
Views: 6097
Reputation: 613511
The documentation says:
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.
Note that the documentation I linked to is the MSDN website. That is your source for the Windows API.
So use WHEEL_DELTA
for one forward click, -WHEEL_DELTA
for one backward click. You'll need to cast the negative value:
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, DWORD(-WHEEL_DELTA), 0);
You don't necessarily need to use multiples of the wheel delta. So perhaps DWORD(-100)
would be fine.
One final point is that SendInput
is preferred to mouse_event
. Probably not an issue for you because you only inject one input event, but using SendInput
is a good habit to acquire.
Upvotes: 9