This one's got me completely stumped.
(New-Object -ComObject 'Shell.Application').Windows() |
ForEach-Object {
if ($_.locationName -contains "My Documents") {
$pwnd = $_.HWND
}
}
$pwnd
$Wnd = Get-WindowPosition -Window ($pwnd)
$SWPArgs = @{Window = $pwnd
Top = 100
Left = (($Wnd.Left) + 100)
Width = (($Wnd.Width) - 100)
Height = (($Wnd.Height) - 100)
}
Set-WindowPosition @SWPArgs
1246322
Get-WindowPosition : Cannot bind parameter 'Window'. Cannot convert the
"1246322" value of type "System.Int64" to type "Huddled.Wasp.WindowHandle".
At line:10 char:35
+ $Wnd = Get-WindowPosition -Window ($pwnd)
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-WindowPosition], Param
eterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Huddled.Wasp.GetW
indowPositionCommand
You'll notice the value of the argument is: 1246322 If I manually type the value in on the command line it works!
PS> $wnd = Get-WindowPosition 1246322
PS> $wnd
Location : {X=1920,Y=0}
Size : {Width=1862, Height=972}
X : 1920
Y : 0
Width : 1862
Height : 972
Left : 1920
Top : 0
Right : 3782
Bottom : 972
IsEmpty : False
I've googled all over to try to figure out how to convert the Init64 to a Huddled.Wasp.WindowHandle without success. Ideas?
BTW: I've tried the argument value 3 ways: $pwnd | ($pwnd) | $($pwnd) all with the same results.