• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UI script fails when run from Mail.app's script menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Rob Jorgensen <email@hidden>
  • Date: Sat, 20 Mar 2004 16:10:10 -0500

At 2:50 PM -0600 3/20/04, Joseph Weaks wrote:
On Mar 20, 2004, at 6:30 AM, Bill Cheeseman wrote:
on 2004-03-19 10:47 PM, Joseph Weaks at email@hidden wrote:
But, when I put a script with this run script line in mail.app's script
menu, it fails. ...So, what is it I need to know about running scripts from applications
that have their own script menu?

If you don't get an answer that works, how about posting the most simplified
version of your script you can write that exhibits this problem...

Here is a simplified version of the function I want, removing the need to run an outside script. 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.

(*
tell application "System Events" to set theProcess to name of (first process whose frontmost is true)
-- This works great from an application's script menu to grab the current app's name, however, it won't work if run from Apple's script menu (since "System Events" becomes the front app. Any workaround for that?
--For testing purposes, we'll set the script to run in mail.app
*)

set theProcess to "mail"

set the clipboard to "If you're seeing this, you failed, you loser!"

tell application theProcess
activate
tell application "System Events"
tell application theProcess
keystroke "c" using command down
delay 1 --give it time to update
end tell
end tell
end tell
tell me to activate
display dialog "The clipboard: " & (the clipboard)

First, the UI part of the script should address the application's process and not the application. Your second instance of "tell application theProcess" should be changed to "tell process theProcess".

In some generic cases it's possible to simply disregard the application process altogether. Does this work?

set the clipboard to "If you're seeing this, you failed, you loser!"

tell application "System Events"
keystroke "c" using command down
delay 1 --give it time to update
end tell

display dialog "The clipboard: " & (the clipboard)

-- Rob
_______________________________________________
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.


  • Follow-Ups:
    • Re: UI script fails when run from Mail.app's script menu
      • From: Joseph Weaks <email@hidden>
    • Re: UI script fails when run from Mail.app's script menu
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: UI script fails when run from Mail.app's script menu (From: Bill Cheeseman <email@hidden>)
 >Re: UI script fails when run from Mail.app's script menu (From: Joseph Weaks <email@hidden>)

  • Prev by Date: Re: UI script fails when run from Mail.app's script menu
  • Next by Date: Re: UI script fails when run from Mail.app's script menu
  • Previous by thread: Re: UI script fails when run from Mail.app's script menu
  • Next by thread: Re: UI script fails when run from Mail.app's script menu
  • Index(es):
    • Date
    • Thread