- hot keys can't be set when NSBGOnly is on. The window is not key,
so the KeyBroadcaster does not pick up key combos
- going to need a different way of defining key combos
-¥ Optimize, this thing is big and slow :(
+¥ Optimize
¥ Apple Events! Apple Events! Apple Events!
+¥ Upcoming songs menu items are disabled after launching iTunes and playing
*/
#import "MenuTunes.h"
- (void)applicationDidFinishLaunching:(NSNotification *)note
{
+ asComponent = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype);
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"menu"])
{
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"Play/Pause", @"Next Track", @"Previous Track", @"Fast Forward", @"Rewind", @"<separator>", @"Upcoming Songs", @"Playlists", @"<separator>", @"PreferencesÉ", @"Quit", @"<separator>", @"Current Track Info", nil] forKey:@"menu"];
{
[refreshTimer invalidate];
}
+ CloseComponent(asComponent);
[statusItem release];
[menu release];
[view release];
[menu addItem:[NSMenuItem separatorItem]];
}
}
+
curTrackIndex = -1; //Force update of everything
[self timerUpdate]; //Updates dynamic info in the menu
NSMenuItem *songItem;
songItem = [[NSMenuItem alloc] initWithTitle:curSong action:@selector(playTrack:) keyEquivalent:@""];
[songItem setTarget:self];
- [songItem setEnabled:YES];
[songItem setRepresentedObject:[NSNumber numberWithInt:i]];
[upcomingSongsMenu addItem:songItem];
[songItem release];
AECreateDesc(typeChar, [script cString], [script cStringLength],
&scriptDesc);
- OSADoScript(OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype), &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
+ OSADoScript(asComponent, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
length = AEGetDescDataSize(&resultDesc);
buffer = malloc(length);
AEGetDescData(&resultDesc, buffer, length);
+ AEDisposeDesc(&scriptDesc);
+ AEDisposeDesc(&resultDesc);
result = [NSString stringWithCString:buffer length:length];
if (![result isEqualToString:@""] &&
([result characterAtIndex:0] == '\"') &&
- (void)timerUpdate
{
int pid;
+
if (GetProcessPID(&iTunesPSN, &pid) == noErr)
{
int trackPlayingIndex = [[self runScriptAndReturnResult:@"return index of current track"] intValue];
+
if (trackPlayingIndex != curTrackIndex)
{
[self updateMenu];
curTrackIndex = trackPlayingIndex;
}
-
+
//Update Play/Pause menu item
if (playPauseMenuItem)
{