• 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: Can anyone tell me why this AppleEvent code isn't working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone tell me why this AppleEvent code isn't working?


  • Subject: Re: Can anyone tell me why this AppleEvent code isn't working?
  • From: Tomas Zahradnicky <email@hidden>
  • Date: Sat, 27 Jul 2002 16:30:22 +0200

If thought that this code would work to tell iTunes to play or pause, but it
doesn't seem to be executing the event, but gives no error on compile and no
problems show up in console. This code is an adaptation from the code that
ClassicSpy uses to send a Quit Event to Classic. I have adapted the daemon
for it so that it has no problems sending a standard Quit Event to iTunes.

AEAddressDesc clasSprt;
AppleEvent anAppleEvent, reply;

if (classicRunning) {
if (AECreateDesc(typeNull, NULL, sizeof(reply), &reply) == noErr) {
if (AECreateDesc('hook', &iTunesPSN, sizeof(ProcessSerialNumber),
&clasSprt) == noErr) {
if (AECreateAppleEvent('hook', 'PIPs', &clasSprt,
kAutoGenerateReturnID, kAnyTransactionID, &anAppleEvent) == noErr) {
// Send the Apple Event.
if(AESend(&anAppleEvent, &reply, kAENoReply, kAENormalPriority,
kAEDefaultTimeout, nil, nil) != noErr)
NSLog(@"iTunes: AESend error");
AEDisposeDesc(&anAppleEvent); // Dispose of the Apple Event.
} //else NSLog(@"AECreateAppleEvent error %d", err);
AEDisposeDesc(&clasSprt);
} //else NSLog(@"AECreateDesc 2 error %d", err);
AEDisposeDesc(&reply);
} //else NSLog(@"AECreateDesc 1 error %d", err);
}

I'm sure the problem is simple, but no examples or reference is telling me
anything as to why this isn't working. Any AppleEvent masters out there to
help me out?

Hello,

I see is two problems here. First is that you don't need to allocate a descriptor for reply event. It will be allocated by AESend if you specify that you _ARE_ interested in the reply and you're not kAENoReply. So the first AECreateDesc is not neccessary. Just use AEInitializeDesc(&reply) instead. Second thing is that you wrongly specify the event's target. You should create a AEDesc &clasSprt with typeProcessSerialNumber and hot type 'hook'. I bet AESend returns procNotFound (-600) error.

-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# Dept of Computer Science, FEE-CTU Prague
_______________________________________________
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.

  • Follow-Ups:
    • Re: Can anyone tell me why this AppleEvent code isn't working?
      • From: Varun Mehta <email@hidden>
References: 
 >Can anyone tell me why this AppleEvent code isn't working? (From: Varun Mehta <email@hidden>)

  • Prev by Date: Using NSToolbar itemForItemIdentifier properly?
  • Next by Date: NSBrowser won't obey on firstResponder and arrowKeys
  • Previous by thread: Can anyone tell me why this AppleEvent code isn't working?
  • Next by thread: Re: Can anyone tell me why this AppleEvent code isn't working?
  • Index(es):
    • Date
    • Thread