applescript - 苹果脚本 | 属性“AXFrontmost”,为什么不能设置为false?
问题描述
我无法将“AXFrontmost”属性值更改为 false
如您所见,这段代码生成了一个循环
tell application "System Events"
set front_process to name of first process whose frontmost is true
tell process front_process
try
repeat while (value of attribute "AXFrontmost") is true
set value of attribute "AXFrontmost" to false
end repeat
on error
get properties of attribute "AXFrontmost"
end try
end tell
end tell
并且相对于属性属性“AXFrontmost”,settable 的值为 true
我发现将最前面的FORCE设置为 false 的方法是切换可见状态:
repeat while (value of attribute "AXFrontmost") is true
set visible to false
delay 0.01
set visible to true
end repeat
另一种方法是使用 CMD + TAB 键码:
repeat while (value of attribute "AXFrontmost") is true
key code 48 using command down
end repeat
那么,为什么会发生这种行为?假设可设置属性为真。
有没有其他方法可以强制属性“AXFrontmost”的值为 false?除了我上面已经提到的那些?
解决方案
好吧,只有一个进程可以是最前面的。
为此,我只想«告诉应用程序查找器激活»这应该为每个进程将最前面的标志设置为 false。要将 Finder 的标志设置为 false,«告诉我激活»应该可以工作。
推荐阅读
- apache-spark - 将列表中元素后的 n 个元素与列表本身连接起来
- javascript - Azure Maps Resize + Javascript 无法正常工作
- testing - 如何在测试期间模拟 Sails.js / Waterline 模型
- reactjs - 从 React SSR 访问 cookie
- javascript - 将 Bootstrap 升级到版本 4 后如何让轮播再次工作?
- asp.net-core - 使用 Serilog(或任何结构化日志库)的 Steeltoe 动态日志配置
- excel - 使用 VBA 登录到安全网页
- c# - 将日期时间转换为带有月份名称的字符串并返回日期不是字符串
- python - 如何重置迭代集合的循环?
- ios - Swift 中的模块化文本占位符块