Apple script - make targeted window always on top

廉价感情. 提交于 2019-12-23 04:23:02

问题


I am trying to write an apple script that when executed, will make the currently focused window "always on top". Is this possible?

In objective-c I can do this on windows my process owns by using [NSWindow setLevel:] but my struggle is to do it for windows my process does not own. So I am now trying to do it via apple script.

I tried this:

global frontApp, frontAppName, windowTitle
delay 3
set windowTitle to ""
tell application "System Events"
    set frontApp to first application process whose frontmost is true
    set frontAppName to name of frontApp
    tell process frontAppName
        set level of window 1 to 3
        tell window 1
            set windowTitle to value of attribute "AXTitle"
        end tell
    end tell
end tell

return {frontAppName, windowTitle}

However this gives me error -

System Events got an error: Can’t make level of window 1 of process "firefox" into type specifier.

来源:https://stackoverflow.com/questions/36960521/apple-script-make-targeted-window-always-on-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!