Reference Frontmost PDF

Hi all,

This short AppleScript takes the title of the frontmost PDF, and pastes the title of the document while you’re writing.

This would be useful for referencing when writing a paper - I use Papers to organize my articles, and it automatically renames PDFs to “Author, Year” so by placing the title in brackets, I have an unobtrusive way of citing while I write.

The one issue I have with this is that for some reason, a Quicksilver trigger doesn’t seem to work - I suspect it’s due to the {command down} part at the end, but I’m not sure. Any help would be appreciated.

M

tell application "System Events"
	get name of window 1 of application process "Preview"
	set doc_name to result
end tell

set thePrefix to text 1 thru ((offset of "." in doc_name) - 1) of doc_name

set the clipboard to "(" & thePrefix & ")"

tell application "System Events" to keystroke "v" using {command down}

The trigger thing can be resolved with adding “delay 0.5” before the command + v line.