Quick Look a URL via a script (Applescript, Automator, Shell-)?

Lion added the ability to Quick Look a URL in an application (like Mail.app). I would like to use that functionality from a script.

Is that possible?

Replay

There is also an Automator action for displaying a website in a Quick Look like window:

Quick Look a URL via a script (Applescript, Automator, Shell-)?

automator -i http://apple.com Desktop/Website\ Popup.workflow

Quick Look a URL via a script (Applescript, Automator, Shell-)?

Yes, it is possible, but not directly from the internet. The file needs to be downloaded first.

qlmanage -p '/path/to/file'

will show the quick look preview for that file. It will also write some debug information to stderr, so I usually append >/dev/null 2>&1 to the end of the command.

In your case, you will need to download the file first in order to get to the Quick Look preview. You also need the proper extension for qlmanage to recognize the file. cd ~/tmp; curl "$url" --O "quicklook.$extension" will download it into ~/tmp (this directory needs to exist) and you will need to set the extension beforehand with extension=${url##*.}.


The final shell script:

cd ~/tmp
url='http://images.apple.com/mac/home/images/hero_30years_then.jpg'
extension=${url##*.}
curl "$url" --O "quicklook.$extension"
qlmanage -p "quicklook.$extension"

And in an applescript:

set quicklookurl to "http://images.apple.com/mac/home/images/hero_30years_then.jpg"
do shell script "cd ~/tmp; url=" & quoted form of quicklookurl & "; extension=${url##*.}; curl \"$url\" --O \"quicklook.$extension\"; qlmanage -p \"quicklook.$extension\""

Category: applescript Time: 2014-03-24 Views: 4

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.167 (s). 12 q(s)