Is there a way to bring up the Quick View Finder using Applescript?

I use Applescript to automate some tasks in OSX Finder. The script opens a folder and selects the first image in this folder. I would like it to also display a quick view window (exactly as if the user had pressed a space bar).

I found a way to quickly start from the command line using qlmanage , but this brings up a static quick view window that is no longer tied to the crawler 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 
+4
source share
2 answers

Updated (thanks Kevin Ballard ):

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

Note: this requires that the “Universal access” control panel select “allow access for auxiliary devices”.

+5
source

If you do not want to do this by creating a Finder script, you can run the following shell command

 qlmanage -p thefile 

In Applescript you can do it like

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

Depending on what you do, this can be a lot easier. Especially if you only have a set of paths.

If you have an existing Applescript path, you can submit it as follows

 set p to POSIX path of mypath do shell script "qlmanage -pr " & quoted form of p 
+11
source

Source: https://habr.com/ru/post/1340729/


All Articles