From ddb628ecbcb78a958bc231e321b78cd072ec8116 Mon Sep 17 00:00:00 2001 From: OKAN TIKTAS <346542017+OKAN-SOFTWARE@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:35:19 -0400 Subject: [PATCH 1/2] fix(win32): add correct int signature for SetCursorPos --- .../src/com/sun/jna/platform/win32/User32.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index a1e43aada..ec6387980 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -2326,6 +2326,21 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, * Returns nonzero if successful or zero otherwise. To get extended * error information, call GetLastError. */ + boolean SetCursorPos(int x, int y); + + /** + * Moves the cursor to the specified screen coordinates. + * + * @param x + * The new x-coordinate of the cursor. + * @param y + * The new y-coordinate of the cursor. + * @return Whether the call succeeded. + * @deprecated Windows expects 32-bit coordinates, so this declaration has + * the wrong calling convention on 32-bit Windows. Use + * {@link #SetCursorPos(int, int)} instead. + */ + @Deprecated boolean SetCursorPos(long x, long y); /** From 11d9663462553d4d90f2ca8a8272b9c1d88b28cf Mon Sep 17 00:00:00 2001 From: OKAN TIKTAS <346542017+OKAN-SOFTWARE@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:35:23 -0400 Subject: [PATCH 2/2] test(win32): verify SetCursorPos signature and Y coordinate --- .../test/com/sun/jna/platform/win32/User32Test.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index 38f82beaa..aefa05722 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -413,6 +413,14 @@ public void testGetCursorPos() { assertTrue("Y coordinate in POINT should be >= 0", cursorPos.y >= 0); } + @Test + public void testSetCursorPosNativeSignature() throws NoSuchMethodException { + assertEquals(boolean.class, + User32.class.getMethod("SetCursorPos", int.class, int.class).getReturnType()); + assertTrue(User32.class.getMethod("SetCursorPos", long.class, long.class) + .isAnnotationPresent(Deprecated.class)); + } + @Test public void testSetCursorPos() { POINT cursorPos = new POINT(); @@ -432,6 +440,8 @@ public void testSetCursorPos() { ), cursorPos2.x == cursorPos.x + 20 ); + assertEquals("Y coordinate should be preserved after SetCursorPos", + cursorPos.y, cursorPos2.y); } @Test