The problem statement is our required application will be running on a remote machine we user will be using that machine via Remote Desktop Connection. The idea is to take screenshots of the application area only, running on that machine. We are able to get application window rectangular bounds via spyxx, window handle is returning correct for the window and processId is accessible but when we are trying to get rectangular bounds we are getting some wrong coordinates. Any help would be appreciated.
var winhandle = NativeMethods.FindWindow("RAIL_WINDOW", null);
if (winhandle != IntPtr.Zero)
{
var mainEMRWindow = AutomationElement.FromHandle(winhandle);
if (mainEMRWindow != null)
{
Console.WriteLine("Bounding Rectangle: " + mainEMRWindow.Current.BoundingRectangle.Left + "," + mainEMRWindow.Current.BoundingRectangle.Top + "," + mainEMRWindow.Current.BoundingRectangle.Right + "," + mainEMRWindow.Current.BoundingRectangle.Bottom);
RECT clientRect = GetClientRect(winhandle);
Console.WriteLine("Client Rect: " + "Left: " + clientRect.Left.ToString() + "," + "Top: " + clientRect.Top.ToString() + "," + "Right: " + clientRect.Right.ToString() + "," + "Bottom: " + clientRect.Bottom.ToString());
Rectangle rc;
GetWindowRect(winhandle, out rc);
Console.WriteLine("Window Rect: " + "Left: " + rc.Left.ToString() + "," + "Top: " + rc.Top.ToString() + "," + "Right: " + rc.Right.ToString() + "," + "Bottom: " + rc.Bottom.ToString());
}
}
I am going to attach the screenshot of the application and code as well. DPI Aware is Per Monitor. Correct Bounding Rectangle is Left 65, Top 10, Right 1793, and bottom 1020 in this case but I'm getting Bounding Rectangle 105, 568, 1108,594 which is wrong.