英文:
How to get installed File Explorer verbs for certain files
问题
我正在为FOOBAR2K制作一个模块,这是一个音乐播放器。这样它可以从终端进行控制和使用,例如Get-FooBar -status
:
我已经覆盖了相当多的内容。我需要的一个功能是添加/追加到当前播放的文件。
我可以轻松地获取一些歌曲并创建一个新的"当前播放"列表:
但有时我需要一种方法来追加到"当前播放列表"。我进行了一些调查,在文件资源管理器中,如果我右键单击Foobar设置为处理的文件,会出现两个来自Foobar的条目:
- "在Foobar中播放"
- "在Foobar中排队"
在资源管理器中对选定的音频文件使用"在Foobar中排队"将这些文件添加到FOOBAR的"当前播放"列表中。
我有兴趣从PowerShell中调用这个动词。我进行了一些搜索和实验:
这篇文章使用PowerShell与Windows资源管理器一起工作 - 脚本博客帮助我找到了文件夹的动词,但以相同的方式传递文件会返回错误:
错误:
操作已停止:
行 |
2 | $Shell.NameSpace('C:\Music Library\Antonio Carlos Jobim - Stone...
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 从对COM组件的调用中返回了错误HRESULT E_FAIL。
我在StackOverflow上找到的答案也遇到了类似的问题。
感谢任何帮助。
英文:
I am working on a module for FOOBAR2K, a music player.
So that it can be controlled and used from the terminal, For example Get-FooBar -status
:
Name Value
---- -----
Artist Antonio Carlos Jobim
Song Amparo
Album Stone Flower
Current Time 0:09
Total Time 3:42
Path C:\Music Library\Antonio Carlos Jobim - Stone Flower\Amparo.flac
I have covered quite a bit of ground. One functionality I need is to add\append to the currently playing playing files.
I can take some songs and create a new "currently playing" list just fine:
Get-ChildItem -path ".\Antonio Carlos Jobim - Stone Flower" -Exclude *sabia*,*amp* | Set-FooBar
But I sometimes need a way to append to the "Currently Playing List". I did some investigation, in File Explorer, If I right click a file that Foobar is set to handle, there are two entries from Foobar:
- "Play in Foobar"
- "Enqueue in Foobar"
Using Enqueue in Foobar
on a selection of audio file in Explorer will add those files to FOOBAR's "Currently Playing" list.
I am interested in invoking this verb from PowerShell. I did some searching and experimenting:
This article Use PowerShell to Work with Windows Explorer - Scripting Blog I was able to find verbs for folders but passing Files in the same way, returns errors:
$Shell = New-Object -ComObject 'Shell.Application'
$Shell.NameSpace('C:\Music Library\Antonio Carlos Jobim - Stone Flower\Amparo.flac').Self.Verbs()
Error:
OperationStopped:
Line |
2 | $Shell.NameSpace('C:\Music Library\Antonio Carlos Jobim - Stone...
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Error HRESULT E_FAIL has been returned from a call to a COM component.
I ran into similar issues with answers I found on StackOverflow as well.
Thanks for any help.
答案1
得分: 1
你在正确的方向上,但你需要使用 shell.Namespace()
方法来获取包含文件的文件夹,然后使用 folder.ParseName()
方法来获取文件的 FolderItem。它的 .Verbs()
方法应该返回文件的有效动作。
由于我现在正尝试在手机上回答,无法复制文件路径,所以当我回到电脑时,我们会详细讨论这个答案。
英文:
You're on the right track, but you have to use the shell.Namespace()
method to obtain the folder that contains the file and then use the folder.ParseName()
method to obtain the FolderItem for the file. Its .Verbs()
method should return valid verbs for the file.
Unable to copy your file path while I'm trying to answer for my phone so we'll flesh this answer out when I get home to my computer.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论