Hi all
I want to use script to do some “open with” work with certain files, could any one be kind enough to help me? I have already done the “open” work, and I searched the forum but can not find the “open with” information.
BTW: where can I find the APIs of the DNTp? I guess it would be more convenient if there is a manual.
thanks
There is an AppleScript dictionary, accessible in File > Open Dictionary in Script Editor.
Can you clarify what you mean by this?
PS: There is no “open with” command.
I use Skim to highlight pdf files. When I open the Skim note I want to open the corresponding pdf file. However, I could only open it with the default pdf reading of DNT and I want to open it with Skim, which could be done by using “open with” menu with right-click.
Here is my script:
tell application id "DNtp"
try
set this_selection to the selection
if this_selection is {} then error "Please select some contents."
repeat with this_item in this_selection
set current_name to the name of this_item
set theTrimLength to length of current_name
set skim_postfix to characters (theTrimLength - 4) thru theTrimLength of current_name as string
if skim_postfix is not ".skim" then
display alert "DEVONThink Pro" message "Not a skim note"
exit repeat
end if
set paper_name to characters 1 thru (theTrimLength - 4) of current_name as string
set paper_name to paper_name & "pdf"
set searchResults to search paper_name within titles
-- can I open the file with Skim?
set theWindow to open window for record (first item of searchResults)
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
Replace ```
set theWindow to open window for record (first item of searchResults)
with ```
if searchResults ≠ {} then
set docPath to path of item 1 of searchResults
tell application "Skim" to open docPath
end if
Thanks a lot.
Another small problem: can I focus to Skim automatically after it opens the pdf file? I mean, when the script runs, it makes Skim to open the file, but no windows shows up, it only stays in the Dock.
Use…
if searchResults ≠ {} then
set docPath to path of item 1 of searchResults
tell application "Skim"
activate
open docPath
end tell
end if
works fine, thanks a lot !