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

Re: Working with currently-selected text


  • Subject: Re: Working with currently-selected text
  • From: kai <email@hidden>
  • Date: Thu, 12 May 2005 03:32:46 +0100


On Wednesday, May 11, 2005, at 02:49 pm, Mark J. Reed wrote:

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:

[code snipped and messed with below]

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?

(Assuming that the relevant app is frontmost when performing clipboard commands):


-------

set the clipboard to ""

tell application "System Events"
    keystroke "c" using command down -- copy

set escTime to (current date) + 1 (* modify as required *) repeat while (count (the clipboard)) is 0 if (current date) > escTime then error "Oops!" (* or whatever *) end repeat

    set theSelection to the clipboard
    muckWith(theSelection)
    set the clipboard to theSelection
    keystroke "v" using command down -- paste
end tell

-------

The 'escTime' stuff is just a thought in case nothing gets selected (and a perpetual loop ensues).

---
kai

_______________________________________________
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>
References: 
 >Working with currently-selected text (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: moving an application window from one display to another
  • Next by Date: Page Setup
  • Previous by thread: Working with currently-selected text
  • Next by thread: Re: Working with currently-selected text
  • Index(es):
    • Date
    • Thread