RE: how can I copy from another app?
RE: how can I copy from another app?
- Subject: RE: how can I copy from another app?
- From: Shawn Bakhtiar <email@hidden>
- Date: Wed, 04 May 2011 18:37:13 -0400
- Importance: Normal
I have not been on this list that long to have heard this abajillion times....
and without knowing what others have said, I can surmise that their replies where no less perplexed with the question "but Why?"
The copy and past function is a user interface object, designed to aid in process flow. It is not designed for any kind of IPC (Inter Process Communication) that one would want to use (unless your trying to make yourself go insane). In any case, if you REALLY want too...
You should write a program that uses the NSPasteboard object, and registers for types that you want to process. I bet there is an update signal you can callback on, so when anything gets pasted to the server you know about it, and from the code bellow it appears like you want to use text, which is a standard type.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008099
But if you have asked this here before, I'm sure someone has already told you all this?
> Date: Wed, 4 May 2011 16:46:04 -0500
> From: email@hidden
> To: email@hidden
> Subject: how can I copy from another app?
>
> I know this has been asked a bajillion times before, yet here we are.
>
> So it turns out that my simple little applescript to copy in from
> another app was ineffective. Lots more digging around led me to create
> this:
>
> tell application "Xcode"
> activate
> tell application "System Events"
> tell application process "Xcode"
> set frontmost to true
> keystroke "c" using command down
> end tell
> end tell
> display dialog (the clipboard)
> set foo to path to frontmost application
> display dialog foo
> end tell
>
> which is currently hardwired to Xcode and has a couple of dialogs for
> debugging purposes. Yes, yes, I know that blissfully assuming that
> command-C performs a copy operation is less than ideal. Best option
> I've seen so far.
>
> Here's the annoying bit - this works just fine when run from the
> Script Editor. But when I run it within my app by firing it off via an
> NSAppleScript call, it fails and copies no text. I even tried saving
> it as a separate script and invoking it via osascript and had no luck.
> Again, that works just fine on the command line calling it directly,
> but not from within the app.
>
> I'm utterly stumped. Is there something simple I'm missing? An option
> to turn on?
>
> Is there some other approach I should try instead?
>
> -Jim....
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden