This function utilizes platform invoke (pinvoke) to provide the X,Y coordinates of a window on the screen as well as its size in height and width.

More information about this function can be found in the following Hey, Scripting Guy! article: TBD

Remember to dot source this script to load the function into the current session.

 

PowerShell
Edit|Remove
. .\Get-Window.ps1
 

 

Help Example:

 

PowerShell
Edit|Remove
<# 
    .SYNOPSIS 
        Retrieve the window size (height,width) and coordinates (x,y) of 
        a process window. 
 
    .DESCRIPTION 
        Retrieve the window size (height,width) and coordinates (x,y) of 
        a process window. 
 
    .PARAMETER ProcessName 
        Name of the process to determine the window characteristics 
 
    .NOTES 
        Name: Get-Window 
        Author: Boe Prox 
        Version History 
            1.0//Boe Prox - 11/20/2015 
                - Initial build 
 
    .OUTPUT 
        System.Automation.WindowInfo 
 
    .EXAMPLE 
        Get-Process powershell | Get-Window 
 
        ProcessName Size     TopLeft  BottomRight 
        ----------- ----     -------  ----------- 
        powershell  1262,642 2040,142 3302,784    
 
        Description 
        ----------- 
        Displays the size and coordinates on the window for the process PowerShell.exe 
         
#>