Add-Type @"
using System;
using System.Text;
using System.Runtime.InteropServices;
"@
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
$desktopProcess = Get-Process -name "explorer"
$documentsProcess = Get-Process -name "explorer"
$desktopHandle = $desktopProcess.MainWindowHandle
$documentsHandle = $documentsProcess.MainWindowHandle
$screenWidth = [System.Windows.Forms.SystemInformation]::VirtualScreen.Width
$screenHeight = [System.Windows.Forms.SystemInformation]::VirtualScreen.Height
$upperHeight = $screenHeight / 2
$upperRect = New-Object System.Drawing.Rectangle(0, 0, $screenWidth, $upperHeight)
$lowerHeight = $screenHeight - $upperHeight
$lowerRect = New-Object System.Drawing.Rectangle(0, $upperHeight, $screenWidth, $lowerHeight)
[User32]::SetWindowPos($desktopHandle, [IntPtr]::Zero, $upperRect.X, $upperRect.Y, $upperRect.Width, $upperRect.Height, 0x0040)
[User32]::SetWindowPos($documentsHandle, [IntPtr]::Zero, $lowerRect.X, $lowerRect.Y, $lowerRect.Width, $lowerRect.Height, 0x0040)