Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Avoid GetLastError result raised from others. #22
It could raise the error from other methods. To specify the error from the method, I recommend to reset the LastError on Windows.
Most functions call SetLastError or SetLastErrorEx only when they fail. However, some system functions call SetLastError or SetLastErrorEx under conditions of success; those cases are noted in each function's documentation.
From checking out the docs for mouse_event, it seems that it doesn't set the "last error", so really this code shouldn't be calling GetLastError() at all. Since mouse_event is deprecated, this code should be calling SendInput(), which does modify the last error. This would make this commit's addition of SetLastError() unneeded.
What we should probably do is call SendInput() to correct the original problem. Thanks for pointing this out! I'll open an issue for it.