-//Return the PSN of iTunes, if it's running
-- (ProcessSerialNumber)iTunesPSN
-{
- NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications];
- ProcessSerialNumber number;
- int i;
-
- number.highLongOfPSN = kNoProcess;
-
- for (i = 0; i < [apps count]; i++)
- {
- NSDictionary *curApp = [apps objectAtIndex:i];
-
- if ([[curApp objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"])
- {
- number.highLongOfPSN = [[curApp objectForKey:@"NSApplicationProcessSerialNumberHigh"] intValue];
- number.lowLongOfPSN = [[curApp objectForKey:@"NSApplicationProcessSerialNumberLow"] intValue];
- }
- }
- return number;
-}
-
-//Send an AppleEvent with a given event ID
-- (void)sendAEWithEventClass:(AEEventClass)eventClass
-andEventID:(AEEventID)eventID
-{
- OSType iTunesType = 'hook';
- AppleEvent event, reply;
-
- AEBuildAppleEvent(eventClass, eventID, typeApplSignature, &iTunesType, sizeof(iTunesType), kAutoGenerateReturnID, kAnyTransactionID, &event, nil, "");
-
- AESend(&event, &reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, nil, nil);
- AEDisposeDesc(&event);
- AEDisposeDesc(&reply);
-}
-