2

I couldn't able to find bounds of an application content.

I'm trying to move mouse to an exact location on the application content using java. For this purpose I need to find location on the application window. Used application for this process has 1024x768 bounds.

This is how I use GetWindowRect:

User32 user32 = User32.INSTANCE;
HWND hWnd = user32.FindWindow(null, "A Random Application");
user32.ShowWindow(hWnd, User32.SW_SHOW);
user32.SetForegroundWindow(hWnd);

RECT bounds = new RECT();
User32.INSTANCE.GetWindowRect(hWnd, bounds);

However, I get following for the bounds:

[(445,141)(1475,938)]

This means window has 1030x797 resolution and it includes border of the window. I need to find where the application content starts(not the window's start point)? How can I achieve that?

Note: When I use GetClientRect I get [(0,0)(1024,768)]. But I can't get x and y.

shyos
  • 1,390
  • 1
  • 16
  • 29

1 Answers1

0

GetClientRect's return value is in client coordinates (relative to the upper-left of the client area). You need to use ClientToScreen to convert client coordinates to screen coordinates -- specifically, converting (0, 0) from client to screen coordinates will tell you the upper-left of the client area relative to the entire screen.

Jeffrey Bosboom
  • 13,313
  • 16
  • 79
  • 92