我正在使用Applescript自动化OSX Finder中的一些任务。该脚本打开一个文件夹并选择该文件夹中的第一个图像。我希望它还会弹出“快速查看”窗口(就像用户按下了空格键一样)。
我确实找到了一种使用qlmanage从命令行启动快速查看的方法,但这会打开一个静态的快速查看窗口,该窗口不再与finder选择相关联。
到目前为止的代码:
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发布于 2011-02-22 11:36:32
更新了(感谢Kevin Ballard):
tell application "System Events" to keystroke "y" using command down注意:这需要在“通用访问”控制面板中选择“启用辅助设备的访问”。
发布于 2011-02-24 01:55:14
如果您不想通过编写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 phttps://stackoverflow.com/questions/5073603
复制相似问题