![首次執行時間啟動 Microsoft Edge 最大化](https://rvso.com/image/1497110/%E9%A6%96%E6%AC%A1%E5%9F%B7%E8%A1%8C%E6%99%82%E9%96%93%E5%95%9F%E5%8B%95%20Microsoft%20Edge%20%E6%9C%80%E5%A4%A7%E5%8C%96.png)
我正在開發一個用於Windows 10 部署的映像,其中一個要求是,當第一次啟動Edge 時,它應該最大化(不是全屏,而是最大化- 與單擊標題欄中的最大化按鈕的結果相同) )。
start-process
我嘗試過使用參數的powershell commandlet -WindowStyle Maximized
,但這並沒有被尊重,例如:
start -windowstyle Maximized microsoft-edge:http://www.example.com
我嘗試過各種 powershell 解決方案來調整其他程式視窗的大小(其想法是產生 Edge 然後調整它的大小),但它們似乎對 Edge 沒有任何影響,例如:
- https://gallery.technet.microsoft.com/scriptcenter/Set-the-position-and-size-54853527
- https://gist.github.com/jakeballard/11240204
我用過過程監控器記錄當我最大化然後關閉 Edge 時發生的情況,我可以看到它設定了註冊表項:
HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main\LastClosedWidth
HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main\LastClosedHeight
桌面的水平和垂直尺寸,但是regedit
當我再次啟動 Edge 時,手動更改這些尺寸不會改變 Edge 的尺寸。
如果 Edge 設為全螢幕然後退出,它將在將來啟動全螢幕 - 有沒有辦法在無需手動幹預的情況下最大化啟動 Edge?
答案1
只需發送 alt+space 的擊鍵,然後 X 最大化視窗。請參閱下面的 powershell 腳本。另存為 .ps1。
start microsoft-edge:http://google.com
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Google - Microsoft Edge')
Sleep 2
$wshell.SendKeys('(%(" "))')
Sleep 2
$wshell.SendKeys('(x)')
答案2
如果您要最大化窗口,則可能不需要 LastClosedWidth 和 LastClosedHeight。以下二進制值儲存最大化視窗的設定。您可以將註冊表設定部署到使用相同螢幕解析度的 PC。
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationFrame\WindowSizing\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge]
"PreferredLaunchViewSize"=hex:80,07,00,00,f0,03,00,00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationFrame\Positions\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge]
"PositionObject"=hex:2c,00,00,00,02,00,00,00,03,00,00,00,ff,ff,ff,ff,ff,ff,ff,\
ff,ff,ff,ff,ff,ff,ff,ff,ff,80,02,00,00,00,00,00,00,40,07,00,00,ac,03,00,00
這些二進位值來自我的系統,目前顯示分辨率設定為 1920x1080。提供了 REG 導出作為範例。