Script dose not work in Canvas X application Script Menu but the script does work in the system scripts menu.
The script copies a word selected in Canvas X text box and looks it up in the Oxford American Dictionary. Canvas X is not a Cocoa application so the contextual menu method dose not work.
When the script is run from the main system script menu it works fine but when I run the same script from Canvas' own script menu it shows a Canvas error dialog:—
Script Execution Error:
≪script≫ doesn't understand the <<event JonsgClip >>message.
Error/Location Code: -1753/0
The script is as follows:
try --incase the clipboard is empty
set clip to the clipboard --get old clipboard
end try
set the clipboard to "" --clear clipboard word count works
set dickLookUp to "" -- text to lookup
tell application "Canvas™X"
set x to selection
if (count of items of x) > 0 then --check that no objects are seleted
tell application "Finder" to display dialog "An object or objects are selected!" & return & "Select a word with the text tool to lookup then retry this script"
return
end if
copy -- I haven't found how to get the selected text without using the clipboard in Canvas.
end tell
set dickLookUp to the clipboard
set wordCount to count of words in dickLookUp
if (wordCount = 0) or (wordCount > 2) then
display dialog "Too many words or no words were selected!" & return & "Select a word to lookup then retry this script"
return
end if
tell application "Dictionary" to activate
tell application "System Events"
tell process "Dictionary"
tell text field 1 of group 1 of tool bar 1 of window "Dictionary and Thesaurus"
keystroke dickLookUp
keystroke return
end tell
end tell
end tell
set the clipboard to clip --reset old clipboard
Why do I get this error only when using the applications script menu?