如何使用AppleScript在Mac上关闭文件选择器对话框?
我的MacOS应用程序中有文件选择器,该应用程序可以通过AppleScript命令来工作:
choose file of type {"", "png", "jpeg", "jpg"} with prompt ""
我目前遇到的问题是用户可以一次打开多个文件选择器对话框。我正在寻找一种在打开新文件选择器对话框之前关闭所有打开的文件选择器对话框的方法,但我对此没有任何进展。 有什么方法可以关闭先前打开的文件选择器对话框?
I have file picker in my macos application that works through AppleScript command:
choose file of type {"", "png", "jpeg", "jpg"} with prompt ""
The problem I currently have is that users can open multiple file picker dialogs at once. I am looking for a way to close all of the opened file picker dialogs before opening a new file picker dialog but I have not no progress with this.
Is there any way to close previously opened file picker dialogs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下脚本将关闭以前打开的应用程序所有实例的“选择文件”对话框。
注意:要用“脚本编辑器”测试上面的脚本,您应该打开2个实例“脚本编辑器”(带有单个“选择文件” 代码行),然后打开“脚本编辑器”的第三个实例,上面的脚本并运行所有内容。首先,运行2首先创建实例。
您可以使用此辅助脚本打开脚本编辑器(或其他应用程序)的实例:
Following script will close "Choose File" dialogs of all instances of your app opened before.
NOTE: to test the script above with "Script Editor", you should open 2 instances of "Script Editor" (with single "choose file" code line) then open 3rd instance of "Script Editor" with script above and run all of them. First, run 2 firstly created instances.
You can open the instances of Script Editor (or, other app) with this helper script: