I wrote a script to do lookups on Thesaurus.com using Safari. Firefox or
Omniweb.
So, I posted it. Paul Berkowitz questioned the complexity of my method of
opening the URL for thesaurus.com, and offered this method: tell application
"Finder" to open location theURL
I made the mistake of believing Paul without testing it. On my Mac, and that
of another user who tried it, this script gives the same error on "open
location" I was getting when using "tell me" or letting Entourage handle the
command, "some data was not the expected type". Or something to that effect.
So, I am herewith reposting the original version of my script, and will
upload a compiled copy to my iDisk, where you can download it using Finder's
Go menu to Open my Public Folder on my iDisk, username allen_a_watson.
Paul, if you can find a better way that works, let me know. I'd love to use
a shorter method.
Script name is "Thesaurus lookup"
property brow : ""
set oc to the clipboard
set the clipboard to ""
tell application "System Events"
set theApp to name of first process whose frontmost is true
tell process theApp
-- Copy selected word
keystroke "c" using command down
end tell
delay 1 -- Wait for clipboard to get set
end tell
set X to the clipboard
set the clipboard to oc
if (count words of X) ‚ 1 then
display dialog "Word to look up?" default answer X
set X to text returned of result
end if
if (length of X) = 0 then
beep
set the clipboard to oc
return
end if
set theURL to "
http://thesaurus.reference.com/search?q=" & X & "&db=roget"
set theApp to my getAppName()
--display dialog theApp
if theApp = "Microsoft Entourage" then
if brow = "" then
try
set brow to default web browser -- WC Handy osax
on error
display dialog "Choose your default web browser" default button
"Safari" buttons {"Firefox", "Omniweb", "Safari"}
set brow to button returned of result
end try
end if
if brow contains "Safari" then
tell application "Safari"
set the URL of document 1 to theURL
activate
end tell
else if brow contains "Omniweb" then
tell application "OmniWeb"
GetURL theURL
activate
end tell
else if brow contains "Firefox" then
tell application "firefox"
Get URL theURL
activate
end tell
else
display dialog "Don't know terminology for " & brow
end if
else
open location theURL
end if
on getAppName()
tell application "System Events"
set f to first process whose frontmost is true
return name of f
end tell
end getAppName