I am trying to maximize my skype window from powershell.
I use the following script...
$sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
$hwnd = @(Get-Process lync)[0].MainWindowHandle
# Restore window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
I also tried
$hwnd = @(Get-Process -id 2560)[0].MainWindowHandle
Info
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1012
But when I run the command it doesn't maximize, just returns true. Can I maximize a Skype window from poershell?
You were close in your question statement, but you are using the wrong constant.
$SW_MAXIMIZE = 3
$sig = @'
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
'@
Add-Type -MemberDefinition $sig -Name Functions -Namespace Win32
$hWnd = (Get-Process -Name lync).MainWindowHandle
[Win32.Functions]::ShowWindow($hWnd, $SW_MAXIMIZE)