Last active
May 30, 2021 02:25
-
-
Save jeremy-farrance/62a6595bd7504276c7f7155f7e3d9bdb to your computer and use it in GitHub Desktop.
PowerShell - Size and Position Windows on Desktop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PS 7.1.3 20210527 JRF | |
# using this Set-Window function (saved to Users/jfarrance/PowerShell/) | |
# https://superuser.com/questions/1324007/setting-window-size-and-position-in-powershell-5-and-6 | |
## unfinished but working | |
-- need to implement detecting AND controlling the window states for minimized/max/normal | |
-- need to detect screen rez and adapt? 2560x1440, 1920x1200, 1920x1080 | |
## future? | |
# Bring Window to Foreground or unMaximize? | |
# https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/bringing-window-in-the-foreground | |
# Outlook main only | |
Set-Window -id (Get-Process OUTLOOK).Id -X 0 -Y 300 -Width 1920 -Height 1000 # -Passthru -Verbose | |
# RDC windows | |
$X = 0 | |
$Y = 264 | |
# https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/getting-process-based-on-window-title | |
$ProcessIDs = (Get-Process | Where-Object {$_.MainWindowTitle -like '*Remote Desktop*'}).Id | |
$ProcessIDs | ForEach-Object { | |
Set-Window -id $_ -X $X -Y $Y -Width 1200 -Height 900 # -Passthru -Verbose | |
$X = $X + 128 | |
$Y = $Y - 28 | |
} | |
# OneNote windows | |
$X = 2560 - 1920 - 160 | |
$Y = 264 | |
$ProcessIDs = (Get-Process | Where-Object {$_.MainWindowTitle -like '*OneNote*'}).Id | |
$ProcessIDs | ForEach-Object { | |
Set-Window -id $_ -X $X -Y $Y -Width 1920 -Height 1080 # -Passthru -Verbose | |
$X = $X - 128 | |
$Y = $Y + 28 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Started life at PowerShell v7.1.3 20210527 JRF
using this Set-Window function (saved to Users/jfarrance/PowerShell/)
https://superuser.com/questions/1324007/setting-window-size-and-position-in-powershell-5-and-6
unfinished but working
-- need to implement detecting AND controlling the window states for minimized/max/normal
-- need to detect screen rez and adapt? 2560x1440, 1920x1200, 1920x1080