我有一个Applescript,它给了我一个结果。但我无法将值解开为字符串,因此我可以使用它。
var set: String = "set windowTile to \"\"\n"
var tell: String = "tell application \"System Events\"\n"
var setFrontApp: String = "set frontApp to first application process whose frontmost is true\n"
var setFrontAppName: String = "set frontAppName to name of frontApp\n"
var tellProcces: String = "tell process frontAppName\n"
var tellFirst: String = "tell (1st window whose value of attribute \"AXMain\" is true)\n"
var setWindowTitle: String = "set windowTitle to value of attribute \"AXTitle\"\n"
var endTellFirst: String = "end tell\n"
var endTellProcess: String = "end tell\n"
var endTell: String = "end tell"
var startAtLoginScript: NSAppleScript = NSAppleScript(source: set + tell + setFrontApp + setFrontAppName + tellProcces + tellFirst + setWindowTitle + endTellFirst + endTellProcess + endTell)
var scriptResult:NSAppleEventDescriptor = startAtLoginScript.executeAndReturnError(errorInfo)!
NSLog ("%@", scriptResult)
NSLog 看起来像这样:
2015-03-14 15:15:14.001 test[7315:161881]
<NSAppleEventDescriptor:'utxt'("test.swift")>
实际结果是一个字符串“test.swift”。我怎样才能解开/解析这个结果?
我试着添加这个:
var number:Int = 1
let result = scriptResult.descriptorAtIndex(number)
我也尝试使用该方法descriptorForKeyword(<#keyword: AEKeyword#>)
,但我不知道设置 AEKeyword 的热度。