Get window position and size C#

991 Views Asked by At

How can I get the size and the position of a Window in C#? I read about the GetWindowRect function, but I do not understand how to use it. Can anyone please give me a example on how to use it? (I'd like to get the position of notepad++)

2

There are 2 best solutions below

0
On

Form.Location.X and Form.Location.Y will give you the X and Y coordinates of the top left corner.

For your own Form application is the code this.

0
On

for your own program,
you can use these options,
"Size",
"Location",
otherwise you need to use "Screen" to get monitor size and get other app window size you want