Danoz,
the save as PDF shortcut does work, though shift-option-command-s isn't particularly easy to hit. Of course, you can always use iKey or some other utility to handle with with a single key press. However, I am trying to find a more powerful archiving solution to fit into my workflow.
rmathes,
While I haven't given up on DEVONthink yet, I have been looking at Together recently. Unfortunately, it seems that it is not applescriptable, which does limit options for automation. However, based on a post I found on Applescript.net,
http://bbs.applescript.net/viewtopic.php?id=19238, I was able to get most of the way into the script for you.
You will need to tailor it to your set-up, but
Code:
tell application "OmniWeb"
activate
if not (exists browser 1) then error "No browser is open."
end tell
tell application "System Events"
try
keystroke "p" using {command down}
tell application process "OmniWeb"
click menu button 1 of sheet 1 of front window
delay 0.1
repeat (* "X times", with x as an integer depending on
position of desired application in menu*)
keystroke (ASCII character 31) -- down arrow key
end repeat
keystroke return
end tell
end try
end tell
I also made some significant additions to the script I posted earlier. Because it is probably overkill for most people, I will post it here instead of editing my earlier post.
-If you have selected some text in the front browser, it sets that text as the title of the page,
-Optionally converts the title to title case
-Presents a dialog box for tagging the file,
-Formats those tags (currently for Punakea, though it would be easy to change it for another program)
-Sets the spotlight comment to the page URL and those tags
-Provided that you enable it in the script, displays a Growl notification that everything went OK (though I should improve the error handling)
Code:
(*
Script to download a webpage in OmniWeb as a single page PDF, named with either
the selected text or the name of the page. Will optionally processes that title for
correct capitalization.
*)
-- Properties for file tagging format; Currently set for Punakea
property tag_prepend : " ###begin_tags###"
property tag_append : "###end_tags### "
property tag_prefix : "@"
property tag_separator : ";"
property tag_spacer : " "
property tag_string : ""
-- Basic settings for handling file tagging after the download
property downloadLocation : path to desktop from user domain as string
property fileExtension : ".pdf"
property titlecase : false -- Change to enable conversion of title to title case
tell application "OmniWeb"
try
activate
if not (exists browser 1) then error "No browser is open."
set theBrowser to front browser
set theURL to the address of theBrowser
set theName to the name of theBrowser
(*Setting window size to get a good width for the PDF
(It doesn't matter for all pages, but it does seem to affect some pages) *)
set oldBounds to bounds of theBrowser
set bounds of theBrowser to {700, 22, 1250, 750}
(*Try to get selected text for the filename, else use page title.
While the command
set this_name to do script "unescape(getSelection())" window this_window
is more elegant, it doesn't work on all pages. *)
tell application "System Events"
set old_clipboard to (the clipboard)
set the clipboard to ""
keystroke "c" using {command down}
if (the clipboard) is not "" then set PDF_name to the clipboard
set the clipboard to (old_clipboard)
end tell
set theName to my formatTitle(theName) --Setting the file name to titlecase, removing illegal characters
-- Displaying the dialog with proposed record name, with the option of adding tags to the file
tell application "OmniWeb"
activate
set theResult to display dialog ¬
"The file will be saved as: " & return & return & (theName) & return default answer ¬
"Enter tags (separated by commas)" buttons {"Change Title", "Cancel", "OK"} ¬
default button 3 with title "Set Title and Tags"
set the_tags to text returned of theResult
-- Changing the title
if (button returned of theResult) is "Change Title" then
set the_result to display dialog ¬
"New Title:" default answer ¬
theName with icon 1 ¬
buttons {"Cancel", "OK"} ¬
default button "OK"
set theName to text returned of the_result
end if
--set file_tags to text returned of the result -- Getting the tags
set tag_string to theURL & my formatTags(the_tags) -- Processing the file tags to encode in the correct format
end tell
tell application "System Events"
try
keystroke "S" using {shift down, option down, command down}
keystroke "d" using {command down} -- Setting save location to the desktop
set value of text field 1 of sheet 1 of front window of application process "OmniWeb" to theName -- Setting the filename
click button 1 of sheet 1 of front window of application process "OmniWeb" -- Clicking the save button
on error errMsg
display dialog errMsg buttons {"Cancel"} default button "Cancel"
end try
set bounds of theBrowser to oldBounds -- Restoring original window boundaries
end tell
on error error_message number error_number
if the error_number is not -128 then display alert "OmniWeb" message error_message as warning
end try
end tell
delay 1.0
set theFile to downloadLocation & theName & fileExtension as alias
my tagFile(theFile, tag_string)
set growlDescrip to theName & " Downloaded Successfully"
my growlNotification("OmniWeb", "PDF Capture", growlDescrip)
on formatTitle(this_text)
if titlecase is true then set this_text to do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of this_text
set searchString to ":"
set replacementString to "- "
set currentDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to the searchString
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacementString
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
set AppleScript's text item delimiters to currentDelimiter
return this_text
end formatTitle
on growlNotification(growlIcon, growlTitle, growlDescrip)
tell application "System Events"
set Growl_active to (name of processes) contains "GrowlHelperApp"
end tell
if Growl_active then
set appName to "MattsNotif"
set notifs to {growlTitle}
tell application "GrowlHelperApp"
register as application ¬
appName all notifications notifs ¬
default notifications notifs ¬
icon of application growlIcon
notify with name growlTitle title growlTitle description growlDescrip application name appName
end tell
end if
return ""
end growlNotification
on formatTags(file_tags)
if file_tags is not "" then
set current_delimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to ", "
set tag_string to tag_spacer & tag_prepend -- Adding the string prefix for Punakea
repeat with i from 1 to the count of text items of the file_tags
set this_tag to text item i of the file_tags
set tag_string to tag_string & (tag_prefix & this_tag & tag_separator)
end repeat
set tag_string to tag_string & tag_append -- Adding the string suffix for Punakea
set AppleScript's text item delimiters to ""
set AppleScript's text item delimiters to current_delimiter
end if
return tag_string
end formatTags
-- Subroutine to tag a file
on tagFile(theFile, tag_string)
tell application "Finder"
try
if (exists theFile) then
set current_comment to comment of theFile
set the comment of theFile to current_comment & " " & tag_string
else
if not (exists file the_file) then error "The file was not created."
end if
on error errMsg
display dialog errMsg buttons {"Cancel"} default button "Cancel"
end try
end tell
end tagFile
Edited 2/24/08 to clean up code
2/25/08 to complete code for print to . . .