A
A
Alexander Shirobokov2014-11-04 17:29:56
.NET
Alexander Shirobokov, 2014-11-04 17:29:56

How to determine the position of someone else's window in .net?

There is a win function "GetWindowRect" which, in fact, should return the position of the window by the process number, but in real life it returns numbers that are far from reality.
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern bool GetWindowRect(IntPtr hwnd, ref RECT rectangle);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int X;
public intY;
public int Width;
public int Height;
}
or so
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
How else can you find out the real position of the window?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aush, 2014-11-04
@konrin

GetWindowRect searches not by process number, but by window handle. The numbers are returned correct.
The window handle can be found, for example, using FindWindow .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question