Re: Copy text to the clipboard
Re: Copy text to the clipboard
- Subject: Re: Copy text to the clipboard
- From: kai <email@hidden>
- Date: Fri, 2 Dec 2005 01:31:24 +0000
On 1 Dec 2005, at 18:37, John R. wrote:
I want to copy selected text into my script from ANY active
application. I need to tell the current application to <get
selection>, or I need to use GUI scripting via: <keystroke "c"
using command down>. But I can't find the name of the active
application or process...
tell application "System Events"
set x to (name of application processes whose frontmost is true)
display dialog item 1 of x
end tell
---> "ScriptEditor" when run under Script Editor;
---> "System Events" when run from the any application via the
script menu.
How do I ask politely for the "process that was active just before
I ran this script"?!
Is there a better way to copy selected text to the clip board?
Running from the Script Menu:
-----------
set appName to (info for (path to frontmost application))'s short name
tell application "System Events"
set process appName's frontmost to true
keystroke "c" using command down
end tell
-----------
Running as an application*:
-----------
tell application "System Events"
tell (get first process whose frontmost is true)
set visible to false
repeat while visible
delay 0.1
end repeat
end tell
keystroke "c" using command down
end tell
-----------
* Launched, for example, from the Dock (to avoid making Finder the
frontmost application).
---
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