COM对象与现有的"另存为"和"打开"窗口交互



是否可以使用COM对象与现有的";另存为";以及";打开";窗户?

CCD_ 1仅列出现有的文件资源管理器窗口;打开";以及";另存为";窗口在其他应用程序(如Notepad++(中打开,您可以通过运行以下命令看到:

$Shell = New-Object -ComObject Shell.Application
ForEach ($Item in $Shell.windows()) {
    Write-Host $Item.LocationName
}

我想在自动热键中使用这个,这个问题在后面https://autohotkey.com/board/topic/102127-navigating-explorer-directories/#entry634365

您可以尝试使用类网,如下所示:

[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.SaveFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "All files (*.*)| *.*"
$OpenFileDialog.ShowDialog() |  Out-Null
$OpenFileDialog.filename

您可以使用BrowseForFolder(),并且有几个选项可以应用于它。

$shell = New-Object -ComObject Shell.Application
$shell.browseforfolder(0,"Pick a folder",20)
$shell.browseforfolder(0,"Your custom message",20,17)

你甚至可以让它显示文件

$shell.browseforfolder(0,"Your custom message",16384,17)

虽然它只是用来选择文件夹,因此得名。它也可以是一个内衬。以下默认为控制面板

(New-Object -ComObject Shell.Application).browseforfolder(0,"Do something",16,3)

我不确定你打算直接从explorer中保存什么。这似乎是一个实际应用程序的功能,比如你提到的记事本++

以下是一些有用的链接

http://wsh2.uw.hu/ch12f.html

http://www.lee-mac.com/directorydialog.html

您可能还想了解ShellExecute 的功能

最新更新