Re: Working with currently-selected text
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