gpt4 book ai didi

macos - AppleScript 术语 : Ways to target a specific object

转载 作者:行者123 更新时间:2023-12-03 17:48:41 25 4
gpt4 key购买 nike

我正在尝试让这个 AppleScript 与我的可编写脚本的应用程序一起使用:

tell application "My App"
tell thing 1 -- my custom class
dosomething -- my custom command
end tell
end tell

我喜欢影响“thing 1”的命令。这可能吗?

或者我是否需要向命令添加一个参数,如下所示:

tell application "My App"
dosomething with thing 1
end tell

不过,我宁愿使用第一个选项。

顺便说一句,以防其他人在对象优先命令中遇到困难:将命令的“类”字段留空并仅在 <responds-to> 中设置方法名称非常重要。元素。

最佳答案

使用对象优先命令并实现 direct-parameter传递自定义类的类型的键。

<responds-to> Cocoa 方法采用一个参数

- (void)dosomething:(NSScriptCommand *)command

关于macos - AppleScript 术语 : Ways to target a specific object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36262782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com