Following Rob Napier's Scripting Bridge tutorial, I was able to set up the generated header for the Database Events app, /System/Library/CoreServices/Database Events.app
. I am now trying to use Scripting Bridge to perform the equivalent of tell database "My Database"
.
The corresponding AppleScript that I am trying to run via Scripting Bridge is:
tell application "Database Events"
tell database "My Database"
-- ...
end tell
end tell
But how do I do this in Scripting Bridge?
The generated header contains:
// An application's top level scripting object.
@interface DatabaseEventsApplication : SBApplication
+ (DatabaseEventsApplication *) application;
- (SBElementArray *) documents;
- (SBElementArray *) windows;
@property (readonly) BOOL frontmost; // Is this the frontmost (active) application?
@property (copy, readonly) NSString *name; // The name of the application.
@property (copy, readonly) NSString *version; // The version of the application.
- (DatabaseEventsDocument *) open:(NSURL *)x; // Open an object.
- (void) print:(NSURL *)x printDialog:(BOOL)printDialog withProperties:(DatabaseEventsPrintSettings *)withProperties; // Print an object.
- (void) quitSaving:(DatabaseEventsSavo)saving; // Quit an application.
@end
//...
@interface DatabaseEventsDocument : DatabaseEventsItem
@property (readonly) BOOL modified; // Has the document been modified since the last save?
@property (copy) NSString *name; // The document's name.
@property (copy) NSString *path; // The document's path.
@end
//...
@interface DatabaseEventsDatabase : DatabaseEventsItem
- (SBElementArray *) records;
@property (copy, readonly) NSURL *location; // the folder that contains the database
@property (copy, readonly) NSString *name; // the name of the database
@end
//...
@interface DatabaseEventsApplication (DatabaseEventsSuite)
- (SBElementArray *) databases;
@property NSInteger quitDelay; // the time in seconds the application will idle before quitting; if set to zero, idle time will not cause the application to quit
@end
Do I need to use the open:
method? Search through databases
? Something else?
I found that using the objectWithName:
method of SBElementArray
worked:
DatabaseEventsApplication *dbevApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.databaseevents"];
DatabaseEventsDatabase *db = [[dbevApp databases] objectWithName:@"My Database"];
UPDATE: This was for a small project that I have posted to GitHub: https://github.com/dtrebbien/Songs-Database-Viewer