diff --git a/keywin/send_input/send_input.c b/keywin/send_input/send_input.c index 4cd1ccf..6c9c765 100644 --- a/keywin/send_input/send_input.c +++ b/keywin/send_input/send_input.c @@ -79,15 +79,16 @@ static PyObject* send_mouse_event(PyObject* self, PyObject* args) { int x_overflow = 0; int y_overflow = 0; + int mouse_data_overflow = 0; for (UINT i = 0; i < number_of_events; i++) { PyObject* mouse_event = PyTuple_GetItem(mouse_event_list, i); const LONG x = PyLong_AsLongAndOverflow(PyTuple_GetItem(mouse_event, 0), &x_overflow); const LONG y = PyLong_AsLongAndOverflow(PyTuple_GetItem(mouse_event, 1), &y_overflow); - const DWORD mouse_data = PyLong_AsUnsignedLong(PyTuple_GetItem(mouse_event, 2)); + const DWORD mouse_data = PyLong_AsLongAndOverflow(PyTuple_GetItem(mouse_event, 2), &mouse_data_overflow); const DWORD flags = PyLong_AsUnsignedLong(PyTuple_GetItem(mouse_event, 3)); - if (x_overflow || y_overflow) { + if (x_overflow || y_overflow || mouse_data_overflow) { return dispose_and_fail(inputs); } diff --git a/tests/test_keywin.py b/tests/test_keywin.py index 7757edd..410993c 100644 --- a/tests/test_keywin.py +++ b/tests/test_keywin.py @@ -71,8 +71,12 @@ def test_mouse_helpers(): assert xbutton2_press() assert xbutton2_release() assert scroll(0) + assert scroll(-1) assert scroll_horizontal(0) + assert scroll_horizontal(-1) assert move(0, 0) assert move_relative(0, 0) assert not move(0xFFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFFF) assert not move_relative(0xFFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFFF) + assert not scroll(0xFFFFFFFFFFFFFFFFF) + assert not scroll_horizontal(0xFFFFFFFFFFFFFFFFF)