Changing display mode without using displayswitch.exe

Hello everyone…

I am looking at possibilities to change my display settings to help with the dual monitor setup

  1. Script should toggle between extended mode and internal mode
  2. With help from various other inputs/scripts. I have the following script to do the job.
Add-Type -AssemblyName System.Windows.Forms

$currDispMode = [System.Windows.Forms.SystemInformation]::VirtualScreen.Width
$oneScrWidth = [System.Windows.Forms.SystemInformation]::WorkingArea.width

switch ($currDispMode)
{
    $oneScrWidth{
		displayswitch.exe /extend
	}

    {$_ -gt $oneScrWidth}{
		displayswitch.exe /internal
	}
}

However it uses displayswitch.exe and it has issues - If the focus is out of displayswitch sidebar, it does not work

Is there any other ways to switch display (without opening displayswitch and preferably more silently) than using displayswitch.exe

Thank You

Anyone have any feedback