I'm currently following a guide to me a simple Auto Clicking application. The guide I'm using utilizes mouse_event
.
Everywhere I look says that mouse_event
is deprecated and that it is better to use SendInput
, but I have yet to find an actual reason why you should use one over the other.
Even the documentation on mouse_event states "Use SendInput instead."
Most of my experience is in java and I am very familiar with thread.stop() being deprecated because it is dangerous. I'm looking for the same type of explanation.
VOID WINAPI mouse_event(
_In_ DWORD dwFlags,
_In_ DWORD dx,
_In_ DWORD dy,
_In_ DWORD dwData,
_In_ ULONG_PTR dwExtraInfo
);
That's the declaration for mouse_event(). After you've done some winapi programming then it will become starkly obvious what is wrong with this function. It doesn't have any way to indicate failure . The keybd_event() function has the same problem. You can for example pass junk values for dwFlags and it just won't work without any way to find out why.
Almost all winapi functions have a return value, BOOL or HANDLE is typical. Which lets the function report failure. You typically call GetLastError() next to find out what went wrong.
Like SendInput() does.
A mouse_event inmediatly makes you think about a device that has a mouse and not all them do.
So when you think about any device that can handle touch gestures, as many mobile and tablet , is much better to have a class that represents them; it also probably keeps the developer thinking about all the other kind of Inputs that it needs to handle or send to make work on as many devices as posible
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.