I want to open a powershell GUI Form of a specific size on a Windows 11 screen of 1920 x 1080 pixels. The system scaling in Settings is set to 125%. This cannot be an unusual configuration.
As a test, I try to open a form that is a quarter of the screen in size, as follows:
Add-Type -AssemblyName System.Windows.Forms
$form = New-Object System.Windows.Forms.Form
$form.width = 960
$form.height = 540
$GuiResponse = $Form.ShowDialog()
The problem is simple - this works perfectly in the Powershell ISE, but I cannot get it to work in the Powershell Console because the window is always significantly larger than it should be - I think because the console is performing some sort of reverse scaling.
I can of course do my own scaling and make the window proportionally smaller so that it is the right size when run from the console - but there's an additional associated issue in that any text written to the window is smudgy as it is being inappropriately scaled (at a guess).
There has been some discussion about this type of issue on Stack Overflow and elsewhere, but nothing I've tried resolves this. Yet it seems such an elementary problem, it surely has a simple solution?