arrange-windows.ps1 859 B

12345678910111213141516171819202122232425262728293031323334
  1. # Keep the demo terminal on the left and PCL/calc on the right.
  2. # ASCII only. Windows PowerShell 5.1 compatible.
  3. param(
  4. [long]$ConsoleHwnd,
  5. [int]$X,
  6. [int]$Y,
  7. [int]$W,
  8. [int]$H,
  9. [int]$PclX,
  10. [int]$PclW,
  11. [int]$Minutes = 20
  12. )
  13. . (Join-Path $PSScriptRoot 'lib-gui.ps1')
  14. if ($ConsoleHwnd -ne 0) {
  15. [PclGui]::Move([IntPtr]$ConsoleHwnd, $X, $Y, $W, $H)
  16. }
  17. $end = (Get-Date).AddMinutes($Minutes)
  18. while ((Get-Date) -lt $end) {
  19. $procs = Get-Process -ErrorAction SilentlyContinue | Where-Object {
  20. $_.MainWindowHandle -ne 0 -and (
  21. $_.ProcessName -like '*Plain*' -or
  22. $_.ProcessName -like '*calc*' -or
  23. $_.ProcessName -like '*Calculator*'
  24. )
  25. }
  26. foreach ($p in $procs) {
  27. [PclGui]::Move($p.MainWindowHandle, $PclX, 0, $PclW, $H)
  28. }
  29. Start-Sleep -Milliseconds 500
  30. }