A while back I had to control iTunes from a Cocoa app using AppleScript and I used NSAppleScript
. I wasn't aware of the Scripting Bridge, and I'll take a look at it, but it was pretty straightforward with NSAppleScript
:
NSString *source = @"tell application \"iTunes\" to set sound volume to sound volume - 1";
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:source];
[script executeAndReturnError:nil];
I never had any trouble controlling iTunes in this manner and I'm sure it would work with FileMaker as well.
One thing I'll mention that made writing the code a tiny bit easier was creating a category on NSAppleScript with the following method:
+ (NSAppleEventDescriptor *)executeWithSource:(NSString *)source {
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:source];
return [script executeAndReturnError:nil];
}
That turned my scripting code into
[NSAppleScript executeWithSource:@"tell application \"iTunes\" ..."];