How Can I Start Programs at Specific Locations on Multiple Monitors Using PowerShell?

0
7
Asked By TechieTurtle42 On

I'm looking to create a startup script for my home office laptop that will automatically launch my programs and position them correctly on my three-display setup. So far, I have this script that opens the applications but doesn't specify where they should appear on the screen. Here's what I have so far:

```powershell
Write-Host "Start VMware Workstation"
& 'C:Program Files (x86)VMwareVMware Workstationvmware.exe'

Write-Host "Start Notepad"
& 'C:Program FilesNotepad++notepad++.exe'
Start-Process -File "$($env:USERProfile)AppDataLocalMicrosoftWindowsAppsms-teams.exe"
```

I'd appreciate any advice on how to set specific coordinates for each window when they open. Thanks!

5 Answers

Answered By DevDude87 On

To get your windows positioned just right, you'll likely need to use the Win32 API together with P/Invoke in PowerShell. While opening the applications is straightforward, adjusting their sizes and positions requires a bit more work. You might want to check out some scripts from the PowerShell Gallery, especially `Set-Window.ps1`, which can help with this.

CuriousCoder33 -

Thanks for the tip! I’ll see if that script matches what I need.

Answered By CodeCrafter8 On

This is definitely doable, but you'll need to dig into P/Invoke and the Win32 API. Look into the user32.dll functions for handling window positioning. There's a resource online that helps with the C++ signatures you’ll need to convert into C#. I have some implementation notes that might help you switch your main monitors back and forth, just let me know if you want to see them!

Answered By WorkspaceWhiz On

Have you considered using Powertoys Workspaces? You can define where your apps should be located, and then create a shortcut to include in your login script. It could make things a lot smoother!

Answered By GadgetGuru99 On

You're right that launching apps is the easy part, but placing them correctly is more tricky. Don't just rely on `Start-Process`; you'll need some tools specifically for window management on top of PowerShell.

Answered By WindowWizard On

I actually built a PowerShell tool for repositioning windows and would love to share it! I just need to get home first to pull it up.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.