【发布时间】:2016-03-12 07:21:46
【问题描述】:
不确定在没有将脚本作为文件并以这种方式运行的情况下,这是否可以在 Objective-c 中实现。
NSAppleScript *appleScriptGetHH = [[NSAppleScript alloc] initWithSource:@\
"tell application \"System Events\"\n \
tell process \"Grabee\"\n \
with timeout of 0 seconds\n \
get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"Demo Window 1" \n \
end timeout \n \
end tell \n \
end tell"];
这很好用,但我想做的是用字符串替换“Demo Window 1”(因为它将在程序中动态更改)
当我使用这样的东西时
NSString *windowName = @"Green Window4";
然后替换这一行:
get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"Demo Window 1" \n \
与:
get value of attribute \"AXValue\" of text area 1 of scroll area 1 of window \"%@" \n \
还有
end tell", windowName];
我收到一个参数太多的错误,有没有办法在不分离脚本的情况下做到这一点?
【问题讨论】: