Has any one had any success in being able to script the Devonthink interface using UI scripting.
This is a simple example to highlight a PDF document using UI scripting that works when run from the Applescript Editor but not when run from Devonthink’s Script menu. When run from the script menu, it hangs for about 15 seconds with the script menu highlighted and then exists without an error message and without apparently doing anything)
try
tell application id "com.devon-technologies.thinkpro2"
do_menu("DEVONthink Pro", "Format", "Highlight") of me
end tell
on error errMsg number errNum
display alert (localized string "An error occured when highlighting") message errMsg as warning
end try
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
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
(the do_menu subroutine comes from http://www.macosxautomation.com/applescript/uiscripting/ and I have found it the most reliable way generally to deal with UI scripting of menus)
Obviously you could do this from the menu if this is all you wanted to do, but in my case I would like to be able to do this from within a script that does several things.
I have searched through the forums but I havent found any other examples of UI Scripting so any ideas would be appreciated.
Frederiko