スクリプト
古いDisplaySwitch.exeが必要です。
# [DisplaySwitch.exe only opens the menu, regardless of the arguments : windowsinsiders](https://www.reddit.com/r/windowsinsiders/comments/uurnqd/comment/ipeoq15/?utm_source=reddit&utm_medium=web2x&context=3) Add-Type -AssemblyName System.Windows.Forms $displayCount = [System.Windows.Forms.Screen]::AllScreens.Count # 接続中のディスプレイ数を入力 $maxDisplayCount = 4 if ($displayCount -eq $maxDisplayCount) { # 拡張→セカンドスクリーンのみ C:\Users\hogehoge\script\DisplaySwitch.exe /external } else { # セカンドスクリーンのみ→拡張 C:\Users\hogehoge\script\DisplaySwitch.exe /extend }
EXE化
PS2EXEというソフトでEXE化した。
MScholtes/PS2EXE: Module to compile powershell scripts to executables
ps2exe .\トグルマルチディスプレイ.ps1 -noConsole
実装のコツ
DisplaySwitch.exe only opens the menu, regardless of the arguments : windowsinsiders
DisplaySwitch.exe
はアップデートで機能が削減されて、オプションが効かなくなった。- 従来はオプションをつければGUI操作が不要だったが、できなくなった。
- 古い
DisplaySwitch.exe
を手に入れよう。 - 古いPCからコピーしてくるかネットで配っているものをダウンロードするといい。