有没有办法触发Finder的“快速查看”功能带有 Applescript 的窗口?

发布于 2024-10-18 20:22:37 字数 629 浏览 1 评论 0原文

我正在使用 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

I am using Applescript to automate some tasks in the OSX Finder. The script opens up a folder and selects the first image in that folder. I would like it to also bring up the "quick look" window (exactly as if the user had pressed the space bar).

I did find a way to fire up quick look from the command line using qlmanage, but that brings up a static quick look window, which is no longer tied to the finder selection.

Code so far:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许仙没带伞 2024-10-25 20:22:37

如果您不想通过编写 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

If you don't want to do it by scripting the Finder you can run the following shell command

qlmanage -p thefile

In an Applescript you might do this like

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

Depending upon what you are doing this might be much easier. Especially if you primarily just have a set of paths.

If you have an existing Applescript path you can send it like this

set p to POSIX path of  mypath
do shell script "qlmanage -pr " & quoted form of p
绿萝 2024-10-25 20:22:37

更新(感谢Kevin Ballard):

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

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

Updated (with thanks to Kevin Ballard):

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

Note: this requires that "enable access for assistive devices" is selected in the "Universal Access" control panel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文