Multi Display - Powershell forms opening on the focus display screen

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
davidrx
Posts: 2
Joined: Mon Sep 15, 2014 1:08 am

Multi Display - Powershell forms opening on the focus display screen

Post by davidrx » Fri Dec 20, 2019 4:09 am

I build a Powershell studio form application which uses external tools and have 3 screens.
When I run my application and I start on of those tools the window opens only on the main screen (similar with credential popup).
How can I let it open on the active screen where my application is running where I started the tool with?

Is there option/setting?

Thanks!

jvierra
Posts: 14155
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Multi Display - Powershell forms opening on the focus display screen

Post by jvierra » Fri Dec 20, 2019 4:16 am

To do this you will have to leverage the desktop API which is not available in the Net Framework. You should also be able to package this as an EXE and it should display in the active session.

User avatar
davidrx
Posts: 2
Joined: Mon Sep 15, 2014 1:08 am

Re: Multi Display - Powershell forms opening on the focus display screen

Post by davidrx » Fri Dec 20, 2019 4:49 am

the compiled exe file opens in the active screen but all popup windows I generated from the app opens from the default main screen.
I think you need to overwrite this default main screen setting somehow.

But maybe not possible with Powershell/Sapien Powershell studio?

jvierra
Posts: 14155
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Multi Display - Powershell forms opening on the focus display screen

Post by jvierra » Fri Dec 20, 2019 8:37 am

That is because the PowerShell engine and the Sapien host are not designed to support multiple screens.

You should ask in the Sapien product support forum to validate this as I have all my monitors in use and cannot set up a test without a lot of pain right now.

Also here is a discussion that references various behaviors of a program in a multi-monitor setup and how to force apps to the desired monitor.

https://www.displayfusion.com/Discussio ... dc4fc3243f

User avatar
localpct
Posts: 309
Joined: Wed Sep 09, 2015 12:53 pm

Re: Multi Display - Powershell forms opening on the focus display screen

Post by localpct » Fri Jan 17, 2020 6:46 am

why not something like

$form1_Load={
#TODO: Initialize Form Controls here
$this.Location = '-500,100'
}
While it might start on the center/main screen, you can use the location to move it to a second monitor. I'm guessing, you want these applications to open in the same spot everyday, and each app you want it displayed on it's own monitor

Locked