Web-Screenshot via Script

Dazu gibt es recht wenig zu sagen… es erspart einem einige Klicks und man kann dabei weiter surfen…

## 25.01.2011 hubionmac.com

## Make a pdf-printout of a URL at your desktop called webscreenshot.pdf

## requires wkpdf (ruby)

## to install open terminal and: sudo gem update –system; sudo gem install wkpdf;gem update wkpdf

##get url to print

set myurl to “”

repeat until myurl starts with “http://” or myurl starts with “https://”

set myurl to text returned of (display dialog “URL?:” default answer “”)

end repeat

##check if name of screenshot file already exists and change if nes…

tell application “Finder” to set myname to my checkname_with_pdf_suffix(“WebScreenshot.pdf”, desktop, false)

##take a screenshot using wkpdf (with background and screen layout)

do shell script “wkpdf –enable-plugins yes –caching no –save-delay 3 –format A4 –stylesheet-media screen –print-background yes –source ” & myurl & ” –output /tmp/wkpdf_out.pdf;mv /tmp/wkpdf_out.pdf ~/Desktop/” & quoted form of myname

##play a sound that makes clear what has just happend!

do shell script “afplay /System/Library/Components/CoreAudio.component/Contents/Resources/SystemSounds/system/Grab.aif”

## put the URL and the date of the screenshot into the file’s comment (this will be lost when copying it to a non-mac-volume!!!)

tell application “Finder” to set comment of item myname of desktop to myurl & return & “@ ” & ((current date) as text)

to checkname_with_pdf_suffix(n, D, looped)

–check if filename exists in D

— so if “A File.pdf” exists it names it “A File 1.pdf”,”A File 2.pdf”,…

tell application “Finder”

set thefiles to name of every item of (D as alias)

end tell

if thefiles contains n then

if looped = false then

set n to ((characters 1 through -5 of n) & ” 1″ & (characters -4 through -1 of n)) as text

my checkname_with_pdf_suffix(n, D, true)

else

set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)

set tmpcount to (count of characters of (tmp as text)) + 5

set tmp to tmp + 1

set n to ((characters 1 through (-1 * tmpcount) of n) & tmp & (characters -4 through -1 of n)) as text

my checkname_with_pdf_suffix(n, D, true)

end if

else

return n

end if

end checkname_with_pdf_suffix