如何使用applescript打开带有quicktime播放器的MP3?

问题描述 投票:0回答:1

我有以下代码来打开文件,但它们都打开了iTunes:

tell application "Finder"
    set the_files to get every file of folder ("Macintosh 
    SSD:Users:myusername:Desktop:DJ:Music:Sort")
end tell

repeat with theItem in the_files
    tell application "QuickTime Player"
        open theItem
    end tell
end repeat

谢谢!

macos automation applescript
1个回答
0
投票

AS语法可能会非常误导。虽然你的open命令在tell application … end tell块中,但这并不一定意味着它将被发送到该应用程序。如果命令的直接参数恰好是对另一个应用程序中对象的引用(在这种情况下,对Finder中的document file对象的引用),则AS会将其发送到该应用程序。

使用set the_files to get every file of folder (…) as alias list。这将为您提供AppleScript alias值的列表,而不是Finder引用列表(除了Finder以外的任何应用程序都无法理解)。

© www.soinside.com 2019 - 2024. All rights reserved.