Re: Thesaurus in Entourage

From: Allen Watson (allenwatson_at_earthlink.net)
Date: 12/30/04


Date: Wed, 29 Dec 2004 18:06:29 -0800

I don't know why, but it didn't work for me. I'm too busy to go back and try
it again (no time yet to work on you-know-what; tomorrow for sure). I'll
save your version and try it later.

For those who are trying to use my script last posted, it had a bug; it
worked for me once, then no longer, and I can't figure how it ever worked!
The fixed version is up on my iDisk. Here is a copy of the source:

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
    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
    tell application brow to activate
    if brow contains "Safari" then
        run script ("tell application \"Safari\" to set the URL of document
1 to \"" & theURL & "\"")
    else if brow contains "Omniweb" then
        run script ("tell application \"Omniweb\" to GetURL \"" & theURL &
"\"")
    else if brow contains "Firefox" then
        run script ("tell application \"Firefox\" to Get URL \"" & theURL &
"\"")
    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

On 12/29/04 3:40 PM, in article BDF8806E.83110%berkowit@spoof_silcom.com,
"Paul Berkowitz" <berkowit@spoof_silcom.com> wrote:

> On 12/29/04 2:15 PM, in article BDF86C9C.CE84%allenwatson@earthlink.net,
> "Allen Watson" <allenwatson@earthlink.net> wrote:
>
>> On 12/27/04 4:22 PM, in article BDF5E760.C84F%allenwatson@earthlink.net,
>> "Allen Watson" <allenwatson@earthlink.net> wrote:
>>
>>> 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.
>
> I can't tell you anything else. It works perfectly here, from the Entourage
> script menu. You also replied to me once already that it worked for you too,
> right? What I tested before was simply
>
> tell application "Finder" to open location "http://www.macnn.com"
>
> and it worked perfectly. Now I've tested a terse version of your script and it
> too works perfectly:
>
>
> 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"
>
> tell application "Finder" to open location theURL
>
>
> ---------------
>
> This works perfectly from the Entourage script menu here.
>
>
> Don't forget with the version you posted just before, since it has a script
> property brow, no one who tries to save the script in Script Editor in
> Panther, or the current version of Smile (since 1.6) will ever be able to save
> the browser name. Scripts made in Script Editoe or Smile 1.6.x will not save
> changes to properties when run for mthe Entourage script menu. If you created
> a bersion in Script Debugger and posted that they can download it.
>
> But I get nothing wrong with the script above. It works very fast too.