如何使用 AppleScript 关闭浮动窗口?

2024-01-06

我的一个应用程序进程偶尔会创建一个浮动窗口,我想以编程方式自动关闭该窗口。

我可以通过其名称检查该窗口是否存在,但随后我无法使用任何方法关闭它close window "windowname" nor tell window "windowname" to close.

E.g.:

tell application "System Events" to tell process "processname"
    if exists window "windowname" then
        close window "windowname"
    end if
end tell

这导致:

错误“系统事件发生错误:进程“processname”的窗口“windowname”不理解“关闭”消息。”

那我怎样才能关闭这个窗口呢?


我可以像这样关闭 Finder 窗口。也许你也可以这样做。

tell application "System Events"
    tell process "Finder"
        click button 1 of window 1
    end tell
end tell
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 AppleScript 关闭浮动窗口? 的相关文章

  • Laravel Post 控制器不工作(Symfony \ Component...)

    我的整个 Laravel 控制器无法工作 当我向该控制器 index 发出 get 请求时 它工作得很好 但是当我向该控制器发送 post 请求来 store 时 它不起作用 当我尝试排除故障时 我开始注释代码或使用 dd 然后很快注意到

随机推荐