0

按照 Rob Napier 的Scripting Bridge 教程,我能够为Database Events 应用程序设置生成的标头,/System/Library/CoreServices/Database Events.app. 我现在正在尝试使用 Scripting Bridge 来执行tell database "My Database".

我试图通过 Scripting Bridge 运行的相应 AppleScript 是:

tell application "Database Events"
    tell database "My Database"
        -- ...
    end tell
end tell

但是如何在 Scripting Bridge 中执行此操作?

生成的标头包含:

// 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

我需要使用该open:方法吗?通过搜索databases?还有什么?

4

1 回答 1

0

我发现使用工作的objectWithName:方法SBElementArray

DatabaseEventsApplication *dbevApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.databaseevents"];
DatabaseEventsDatabase *db = [[dbevApp databases] objectWithName:@"My Database"];

更新:这是我发布到 GitHub 的一个小项目: https ://github.com/dtrebbien/Songs-Database-Viewer

于 2013-01-11T12:51:49.677 回答