Re: UI script fails when run from Mail.app's script menu
Re: UI script fails when run from Mail.app's script menu
- Subject: Re: UI script fails when run from Mail.app's script menu
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 20 Mar 2004 16:53:10 -0500
on 2004-03-20 3:50 PM, Joseph Weaks at email@hidden wrote:
>
The goal is to have a generic applescript to
>
be used in any application with a script menu, that will copy the
>
selected text using UI scripting. To test it, you must have some text
>
selected in the front window of Mail.app. The script runs fine from
>
Smile, but fails as a compiled script within Mail.app's script menu.
I don't have a definitive answer for you, but here's what I think is
happening. Applications that implement Scripts menus are responsible for
setting up the context in which the script executes. There have been some
posts to this list, recently I think, discussing how it should be done. Not
all apps do it right.
I tried a variant of your script in Mail and in OmniOutliner, with the same
results you obtained. In Mail, I see the Edit menu title flash, which tells
me that GUI Scripting is in fact sending the keystroke to Mail. I suspect
that Mail doesn't quite know what to do with the keystroke once it is
received. In OmniOutliner, I don't even see the Edit menu flash.
When I run the same script from Apple's system-wide Script menu, where it is
found in the Mail app Scripts folder, it works perfectly. I credit this to
Apple's having set up the context correctly there, but what do I know.
This is not a matter of needing to bring another app to the front to "set"
the new clipboard value. I tried that and it doesn't help.
Here's a simpler version of the test script:
set the clipboard to "Wrong clipboard"
tell application "Mail" to activate
tell application "System Events"
tell process "Mail"
keystroke "c" using command down
display dialog (the clipboard)
end tell
end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.