• 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: Sending a paste event to another app?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a paste event to another app?


  • Subject: Re: Sending a paste event to another app?
  • From: Chilton Webb <email@hidden>
  • Date: Tue, 18 Dec 2001 07:37:50 +1345

The real trick is to see whether or not the target app can respond to an AEPaste event. If it CAN, then you're probably doing it right. However, you could test it with an AppleScript fairly easily.

tell application "whatsit"
paste
end tell

if it returns an error, or doesn't work right, that app won't handle your event properly. As has been pointed out earlier, sending the AEpaste event is not always a good idea. Any chance you can fill us in on why you want to do this? If so, perhaps someone on the list will be able to give you an alternative suggestion that might work better.

-Chilton


On Tuesday, December 18, 2001, at 06:24 AM, Steve Moon wrote:

Hi

my AppKit application need to automatically paste some data from its pasteboard to another application. In fact it is required that my app paste the data contents automatically : basically my app need to execute the equivalent of the keyboard shortcut CMD-V to any app.
Is there an easy way for doing that ?? I was thinking that by using some AppleScript I can probably send the event ID kAEPaste to the final application but I can't find any example that explain how to proceed. Right now my code looks like :

[... code to activat the final application + some wait time...]
// frontProcess below is initialize using : GetFrontProcess() from Carbon
myErr = AECreateDesc(typeProcessSerialNumber, &frontProcess, sizeof(ProcessSerialNumber), &addr);
myErr = AECreateAppleEvent(kAEMiscStandards, eventID, &addr, kAutoGenerateReturnID, kAnyTransactionID, &actionEvent);
myErr = AESendMessage(&actionEvent, NULL, kAENoReply, kNoTimeOut);

But this code does nothing... it does not crash but nothing happen. And yes my pasteboard is correctly set since by doing a CMD-V in the final app I got the right data pasted in the app.

Steve
Note: my app do not know in advance what is the final application where the Paste event should occur; this is something that the user can define at will : it could be a Cocoa app (like TextEdit), a Carbon app (like Internet Explorer), ... and so I can not add my custom code in this final app for handling this case : my app need so to activate first the final app and send the Paste event.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Sending a paste event to another app? (From: Steve Moon <email@hidden>)

  • Prev by Date: Re: PB/IB things that have stopped working
  • Next by Date: Re: Drawer: drag-n-drop destination?
  • Previous by thread: Re: Sending a paste event to another app?
  • Next by thread: Dock Problems
  • Index(es):
    • Date
    • Thread