Open folder and maximise the folder window

前端 未结 2 366
死守一世寂寞
死守一世寂寞 2021-01-16 07:20

I have the following simple Powershell script:

ii E:\\Source\\Development\\websites\\example.com.au\\root
ii E:\\Source\\Development\\websites\\example.com.a         


        
相关标签:
2条回答
  • 2021-01-16 07:28

    Use AppActivate method, don't forget to send Enter key to gain focus, then Alt Spacebar X ("% X") to maximize.

    $folder = "C:\Temp"
    ii $folder
    Start-Sleep -m 100
    [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
    [Microsoft.VisualBasic.Interaction]::AppActivate("$folder")
    Start-Sleep -m 100
    [void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
    [System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
    [System.Windows.Forms.SendKeys]::SendWait("% X")
    

    Wrap a loop and you are all set.

    0 讨论(0)
  • 2021-01-16 07:45

    You can use start-process instead of invoke-item, which will give you control of the window size. You can implement that with miminmal changes to the script by creating an ii function to override the alias temporarily, and then remove it when you're done:

    function ii { start-process explorer -WindowStyle Maximized -ArgumentList $args[0] }
    ii E:\Source\Development\websites\example.com.au\root
    ii E:\Source\Development\websites\example.com.au
    ii E:\Source\Development\websites\example.com.au\css
    ii E:\Source\Development\websites\example.com.au\database
    ii E:\Source\Development\websites\example.com.au\js
    Remove-Item function:ii
    
    0 讨论(0)
提交回复
热议问题