- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想获取当前事件应用程序的属性。我知道这应该可以通过 ScriptingBridge 实现,但是,这似乎需要您生成一个 sdef 文件并将其导入到您想要定位的应用程序的项目中。由于我想定位所有应用程序,还有其他方法可以做到这一点吗?
访问系统首选项的示例:
SystemPreferencesApplication *systemPreferences =
[SBApplication
applicationWithBundleIdentifier:@"com.apple.systempreferences"];
如果有其他方法可以访问任何事件应用的属性,请分享。 (例如;窗口标题)
谢谢。
最佳答案
我假设您想运行一个 applescript。如果您有大量的 applescript 代码要运行,那么脚本桥是很好的选择。但是,如果您的数量很少,那么更简单的方法是使用 NSApplescript。
例如,如果您想运行此 applescript...
tell application "System Events"
set theProcesses to processes
repeat with aProcess in theProcesses
tell aProcess to get properties
end repeat
end tell
那么你可以这样写...
NSString* cmd = @"tell application \"System Events\"\nset theProcesses to processes\nrepeat with aProcess in theProcesses\ntell aProcess to get properties\nend repeat\nend tell";
NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:cmd];
NSDictionary* errorDict = nil;
NSAppleEventDescriptor* result = [theScript executeAndReturnError:&errorDict];
[theScript release];
if (errorDict) {
NSLog(@"Error:%@ %@", [errorDict valueForKey:@"NSAppleScriptErrorNumber"], [errorDict valueForKey:@"NSAppleScriptErrorMessage"]);
return;
}
// do something with result
NSLog(@"result: %@", result);
关于objective-c - 没有 sdef 的 ScriptingBridge? ( cocoa ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915668/
我正在尝试使用 ScriptingBridge 编写一个小型 iTunes Controller 。问题是找到一种有效的方法来在发生任何变化时收到通知。我的第一个方法是循环轮询输入并不断检查差异。但我
我是 Objective-C 的新手。 我在过去 2 个月内编写了我的第一个应用程序。我现在正在尝试访问 iTunes 信息,编码似乎很简单,但我找不到 ScriptingBridge.framewo
我正在使用脚本桥从我的 osx 应用程序控制 Spotify。 我正在创建一个应用程序对象,如下所示: var spotify: AnyObject = SBApplication(bundleIde
我已经广泛搜索了这个问题的答案,但没有找到,所以我在这里问。我正在尝试使用 Swift 读取 iTunes 中的当前轨道,但每当我尝试引用任何 iTunes 类(iTunesApplication、i
我正在尝试编写一个用于快速控制 iTunes 的应用程序。但是在初始化应用程序时返回一个AnyObject类型的对象,但必须是iTunesApplication。 此对象不响应 iTunes 的方法和
目前我正在尝试通过 ScriptingBridge 实现对 iTunes 的多个版本的支持。 例如,属性 playerPosition 的方法签名从 (10.7) 更改 @property NSInt
上下文:我正在处理 a Pharo/Smalltalk -> Objective-C bridge 场景:在以下 Objective-C ScriptingBridge 片段中: iTunesAppl
我的问题的动机是以下文档,它描述了如何使用 ScriptingBridge 集成 mail.app: http://developer.apple.com/mac/library/samplecode
我正在开发一个 Cocoa 应用程序,用于监视您在 iTunes 中收听的内容,并且由于我的目标是 Mac OS 10.5 及更高版本,因此我决定使用 Scripting Bridge . 如果我尝试
我正在尝试使用 ScriptingBridge 读取 iTunes 当前正在播放的轨道。我在这里发现了其他几个线程,但似乎没有一个适合我(macOS Mojave 和 iTunes 12.9.4)。
在我的 Swift 项目中,我需要通过 ScriptingBridge 框架与 iTunes 通信。根据 Apple 文档,我使用 sdef/Applications/iTunes.app | 创建了
是否可以使用 Scripting Bridge 框架获取最前面窗口的 POSIX 路径或目标? 我正在使用 FinderApplication *theFinder = [SBApplication
我想在特定位置打开一个特定大小的新 Finder 窗口并显示特定文件夹。 在 ScriptingBridge(XCode 6、Mavericks 9.4)中,我可以打开一个新的 Finder 窗口,并
我想获取当前事件应用程序的属性。我知道这应该可以通过 ScriptingBridge 实现,但是,这似乎需要您生成一个 sdef 文件并将其导入到您想要定位的应用程序的项目中。由于我想定位所有应用程序
我目前正在尽最大努力,但仍一事无成。我可以使用 iTunes.currentTrack 获取当前轨道,但是 .artworks() SBElementArray 并没有真正帮助我,因为我不知道如何处理
我正在尝试使用 ScriptingBridge 从另一个沙盒应用程序编写一个沙盒应用程序(我编写的)脚本。我在目标应用程序的 sdef 中设置了访问组,并在脚本应用程序的沙箱权利中配置了权利。但是,当
我一直在尝试弄清楚如何使用脚本桥获取当前正在播放的歌曲的 iTunes 图稿。我已经达到了它适用于某些歌曲的地步,但对于其他歌曲,我得到了 SIGABRT。我不确定可能是什么问题,所以任何帮助将不胜感
问题... 自 MacPerl is no longer supported on 64bit perl ,我正在尝试替代框架来控制 Terminal.app。 我正在尝试ScriptingBridg
我正在使用 sdef 实用程序生成的 Finder.h header ,并且许多 Finder SB 方法似乎需要 FinderItem 类型的对象来执行任何有意义的操作。 我将如何根据文件的路径或
我可以使用以下 AppleScript 打开“终端”选项卡: tell application "Terminal" set myTab to do script "exec sleep 1"
我是一名优秀的程序员,十分优秀!