• 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
Working with currently-selected text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Working with currently-selected text


  • Subject: Working with currently-selected text
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 11 May 2005 09:49:12 -0400

I'm trying to write a script to muck with the current text selection irrespective of the application the text is selected in.

Since I don't mind nuking the contents of the clipboard, I thought this would work:

tell application "System Events"
    keystroke "c" using command down -- copy
    set theSelection to the clipboard
    muckWith(theSelection)
    set the clipboard to theSelection
    keystroke "v" using command down -- paste
end tell

but this gets me the old clipboard contents since I'm grabbing the clipboard before the app has a chance to receive and act on the command-C.
 
Is there a reliable way to wait for the clipboard to be updated by the copy command before proceeding? 

--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Working with currently-selected text
      • From: kai <email@hidden>
  • Prev by Date: Re: keyboard mapping
  • Next by Date: OT: desktop picture modes
  • Previous by thread: Re: Shortcut keys
  • Next by thread: Re: Working with currently-selected text
  • Index(es):
    • Date
    • Thread