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.
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
davidrx
Posts: 3
Last visit: Sun Oct 15, 2023 1:16 am

Multi Display - Powershell forms opening on the focus display screen

Post by davidrx »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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: 3
Last visit: Sun Oct 15, 2023 1:16 am

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

Post by davidrx »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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: 397
Last visit: Thu Oct 27, 2022 5:57 am

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

Post by localpct »

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
This topic is 4 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked