I am trying to simulate a mouse click in a window using JNA.
public class App { public static final int WM_LBUTTONUP = 514; public static final int WM_LBUTTONDOWN = 513; public static final int WM_LBUTTONDBLCLK = 0x203; static int WM_CLOSE = 0x10; final static String winTitle = "Untitled - Notepad"; public static void main(String[] args) throws InterruptedException { User32Extra user32 = (User32Extra) Native.loadLibrary("user32", User32Extra.class, W32APIOptions.DEFAULT_OPTIONS); WinDef.HWND hwnd = user32.FindWindow(null, winTitle); user32.SetForegroundWindow(hwnd); Thread.sleep(1000); long y = 77 + (22 << 16);
He will find the window and bring it to the fore. but mouse click does not work. Also sending is WM_CLOSE. What is wrong with a mouse click? Tested on a calculator and notepad. The coordinates relate to the window.
source share