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”,可设置的值为true

我发现强制最先设置为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

那么,为什么会发生这种现象?假设 settable属性为true。

是否还有其他方法可以将属性“ AXFrontmost”的值强制设置为false?除了我上面已经提到的那些?

解决方法

嗯,只有一个进程可以位于最前面。

为此,我只是«告诉应用程序查找器激活» 这应该将每个进程的最前标志设置为false。 要将Finder的标志设置为false,应该可以«告诉我激活»。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...