I'm attempting to write an application that can get a Window HWND pointer based on the mouse location. I've seen working apps and source code in C++ but for some reason this isn't working for me. The results I get from "WindowFromPoint" always return the same 2 HWND's and they are usually my own Java app's HWND. I am doing this while I try to drag a JLabel, I've even attempted to add an offset in case it is simply finding my cursor or JLabel item I'm dragging. Anyone know if I'm doing something wrong here? Thanks! Below is an example...
public interface User32 extends W32APIOptions {
User32 instance = (User32) Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
boolean ShowWindow(HWND hWnd, int nCmdShow);
boolean SetForegroundWindow(HWND hWnd);
HWND FindWindow(String winClass, String title);
boolean GetCursorPos(int[] ascoor);
HWND WindowFromPoint(int xPoint, int yPoint);
}
...
int[] getPos = new int [2];
User32.instance.GetCursorPos(getPos);
HWND hwnd = User32.instance.WindowFromPoint(getPos[0], getPos[1]);
System.out.println(getPos[0] + "," + getPos[1]);