I would like to realize the code taken from this answer and simulate a click without simulating mouse movement inside non-java app window. I know about JNA which, in theory, should have all WinAPI functions. The latest JNA version is 5.6.0 but I didn't find something similar to MAKELPARAM.
POINT pt;
pt.x = 30; // This is your click coordinates
pt.y = 30;
HWND hWnd = WindowFromPoint(pt);
LPARAM lParam = MAKELPARAM(pt.x, pt.y);
PostMessage(hWnd, WM_RBUTTONDOWN, MK_RBUTTON, lParam);
PostMessage(hWnd, WM_RBUTTONUP, MK_RBUTTON, lParam);
Does anyone know if there is something similar in Java or JNA?
Please do not suggest Java Robot. I have tried it, but unfortunately the mouse cursor moves (disappears) by about a milliseconds from the starting position to the point where you need to click and back to the starting position.
public void performClick(int x, int y) {
Point origLoc = MouseInfo.getPointerInfo().getLocation();
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(origLoc.x, origLoc.y);
}