View Single Post
I am in the middle of scripting a solution to use with DEVONthink Pro right now. Here is what I have so far:

Code:
(* Script to download a webpage in OmniWeb as a single page PDF 
with named with either the selected text or the name of the page.  
If you choose, it will also processes that title for correct capitalization.*)


(* If uncommented, this will process the eventual title for correct capitalization 
by loading the Capitalize Script Library written by Christiaan Hofman and 
available at his page: 
http://www.physics.rutgers.edu/~hofman/applescript/

You will also need to uncomment a section near the end of the script.*)

--set capitalizeLib to (load script file ¬
--((path to home folder as string) & "Library:ScriptingAdditions:Capitalize.scpt"))

tell application "OmniWeb"
	try
		activate
		if not (exists browser 1) then error "No browser is open."
		
		set this_window to browser 1
		set this_url to address of this_window
		set PDF_name to the name of this_window
		
		(*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 bounds of this_window 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)
			
			
			-- Uncomment this section also if you want to implement title processing
			--tell capitalizeLib
			--	set PDF_name to capitalize(PDF_name)
			--end tell
			
			-- Executing key command to save page as the displayed title to the desktop
			keystroke "S" using {shift down, option down, command down}
			
			-- Manipulating the save dialog box
			tell application process "OmniWeb"
				keystroke "d" using {command down} -- Setting save location to the desktop
				set value of text field 1 of sheet 1 of front window to PDF_name -- Setting the filename
				click button 1 of sheet 1 of front window -- Clicking the save button
			end tell
			
		end tell
	end try
end tell
Over the next couple of days, I am going to implement a dialog box that lets you double check the name and input or select tags for the file to be written to the Spotlight comments section by the finder. For use with Together, you might might to use a folder action script to subsequently import the file. This could perhaps be configured to only process files with a certain character/string appended to the title or a spotlight comment.

I'd really appreciate any suggestions people might have for improving or extending this script.