单击 NSAlert 中按钮的 AppleScript 代码
我有一个 Mac 应用程序,一旦打开(在 awakeFromNib
中),就会向用户显示一个带有两个按钮的 NSAlert
,一个带有“Option1”,另一个带有“Option2”。我想自动执行以下流程:
- 从“应用程序”文件夹中打开应用程序。
- 通过单击 NSAlert 中的按钮选择“Option2”
到目前为止,我只完成了第一部分:
tell application "Finder"
activate
make new Finder window to startup disk
open application file "My Application.app" of folder "Applications" of startup disk
close Finder window 1
end tell
任何人都可以帮助我编写代码吗?我知道我可以使用系统事件命令来捕获此单击事件,但无法在网上找到任何帮助来单击 NSAlert 中的按钮,而不是在常规窗口中。
I have an mac application that once opened (in awakeFromNib
) shows the user an NSAlert
with two buttons, one with "Option1", the other with "Option2". I would like to automate the following flow:
- Open the application from the Applications folder.
- Choose "Option2" by clicking the button in the NSAlert
So far I've managed to do only the first part:
tell application "Finder"
activate
make new Finder window to startup disk
open application file "My Application.app" of folder "Applications" of startup disk
close Finder window 1
end tell
Can anybody help me with the code? I understand that I can use the System Events commands to catch this click event, but can't manage to find any help online for clicking a button in an NSAlert, and not in a regular Window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以试试这个...
You might try this...
您打开了多少个窗户?大概是越来越混乱了。
如果您需要程序UI浏览器,通常可以找到GUI脚本的正确术语。我不确定是否值得为此购买,但您可以在演示模式下运行该程序一个月,并使用它来找到合适的条款。
http://pfiddlesoft.com/uibrowser/
How many windows do you have open? It's probably getting confused.
If you need to the program UI Browser can generally find the proper terms for GUI Scripting. I'm not sure it's worth buying just for this but you can run the program in demo mode for a month and use it to find the proper terms.
http://pfiddlesoft.com/uibrowser/