# Select a window

**URL:** <https://forums.powershell.org/t/select-a-window/19665>\
**Category:** PowerShell Help\
**Created:** [June 21, 2022, 9:21am UTC](https://forums.powershell.org/t/select-a-window/19665 "2022-06-21T09:21:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Gloops](https://avatars.discourse-cdn.com/v4/letter/_/d9b06d/32.png) [@\_Gloops](https://forums.powershell.org/u/_Gloops)\
**Post date:** [June 21, 2022, 9:21am UTC](https://forums.powershell.org/t/select-a-window/19665/1 "2022-06-21T09:21:14Z")

</div>

Hello everybody,  
With PowerShell I could select windows opened on directories like this :

```auto
$a = New-Object -com "Shell.Application"; $b = $a.windows() | select-object HWND, LocationName; $b;

```

OK, but then I should like to reduce the windows (or I should like to do tests by changing the dimensions).  
I found a script that does this :

> <https://gist.github.com/lalibi/3762289efc5805f8cfcf#file-set-windowstate-ps1>

Oh well, I was happy I had everything needed …  
Hum, let us calm down : this script needs the handle of the window. So, I sent the hWnd, and told it look at that it is the handle.  
Oh it was not happy with that.  
There is the possibility to use a IWin32Window to convert the hWnd to a handle, but I am pretty sure it is not the most direct way of doing it, as the Windows APIs use hWnds, not handles.  
Must I write myself a PowerShell function that calls the Windows APIs to manage windows from hWnds, or did anybody already do it and I have only to download ?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/select-a-window/19665/2 "2024-05-16T20:17:47Z")

</div>

Closed on May 16, 2024, 8:17pm UTC


