Re: Can anyone tell me why this AppleEvent code isn't working?
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: Varun Mehta <email@hidden>
- Date: Sat, 27 Jul 2002 11:33:07 -0400
On 7/27/02 10:30 AM, "Tomas Zahradnicky" <email@hidden> wrote:
>
> 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
It does not give me this error. Error checking is reporting that the
AppleEvent was sent successfully.
I have tried your suggestions and still I get no error but also no result, I
know for a fact that the EventID is 'PIPs', which I translated into Hex but
I still get no result.
_______________________________________________
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.