5

我正在使用 Applescript 自动执行 OSX Finder 中的一些任务。该脚本打开一个文件夹并选择该文件夹中的第一个图像。我希望它也能调出“快速查看”窗口(就像用户按下了空格键一样)。

我确实找到了一种使用qlmanage从命令行启动快速查看的方法,但这会打开一个静态快速查看窗口,该窗口不再与查找器选择相关联。

到目前为止的代码:

property folderPath : "/Volumes/Media/Images"

on run {}
    tell application "Finder"
        activate
            set imageFolder to folder (folderPath as POSIX file)
            set imageFile to first item of imageFolder
            select imageFile
            -- show quick look?
    end tell
end run
4

2 回答 2

12

如果您不想通过编写 Finder 脚本来执行此操作,则可以运行以下 shell 命令

qlmanage -p thefile

在 Applescript 你可能会这样做

do shell script "qlmanage -p " & "thepath/thefile"

取决于你在做什么,这可能会容易得多。特别是如果您主要只有一组路径。

如果你有一个现有的 Applescript 路径,你可以像这样发送它

set p to POSIX path of  mypath
do shell script "qlmanage -pr " & quoted form of p
于 2011-02-23T17:55:13.820 回答
5

更新(感谢凯文巴拉德):

tell application "System Events" to keystroke "y" using command down

注意:这需要在“通用访问”控制面板中选择“启用辅助设备访问”。

于 2011-02-22T03:36:32.157 回答