[OS X TeX] Applescript for BibDesk

Claus Gerhardt claus.gerhardt at urz.uni-heidelberg.de
Tue Sep 21 14:20:30 EDT 2004

Below is a slight modification of my first  Applescript for BibDesk 
which cuts the content of any field where the cursor is, say the 
content is  "arXiv:hep-th/9803179", and replaces it with


The script could of course be easily modified to suit other needs.


-- Applescript for BibDesk
-- arXiv
-- Claus Gerhardt, September 2004

on do_menu(app_name, menu_name, menu_item)
		-- bring the target application to the front
		tell application app_name
		end tell
		tell application "System Events"
			tell process app_name
				tell menu bar 1
					tell menu bar item menu_name
						tell menu menu_name
							click menu item menu_item
						end tell
					end tell
				end tell
			end tell
		end tell
		return true
	on error error_message
		return false
	end try
end do_menu

do_menu("BibDesk", "Edit", "Select All")
do_menu("BibDesk", "Edit", "Cut")
tell application "BBEdit"
	set pasteItem to (contents of current clipboard)
end tell
set n to (number of characters of contents of pasteItem)
set i to 1 as number

repeat while i < (n + 1)
	if character i of pasteItem is equal to ":" then
		set k to i
		exit repeat
		set i to (i + 1)
	end if
end repeat

set pasteText to characters (k + 1) thru n of pasteItem as string

tell application "Bibdesk"
	set pasteName to "\\href{http://arXiv.org/abs/" & pasteText & "}{"
end tell
tell application "System Events"
	tell process "BibDesk"
		keystroke pasteName
	end tell
end tell
do_menu("BibDesk", "Edit", "Paste")
tell application "System Events"
	tell process "BibDesk"
		keystroke "}"
	end tell
end tell

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>

More information about the MacOSX-TeX mailing list