Applescript - 获取窗口状态(可见或在 Dock 中) [英] Applescript - Get status of windows ( Visible or in the dock )

查看:76
本文介绍了Applescript - 获取窗口状态(可见或在 Dock 中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 appleScript 需要一些帮助.

I need some help for my appleScript.

对于所有打开的窗口,我想知道哪个是隐藏的(在 Dock 中),哪个是可见的,哪个是聚焦的?

For all open windows, I want to know which one is hidden (in the dock), which one is visible and which one is focused?

要列出我使用的窗口:

tell application "System Events"
    set procs to processes
    set windowName to {}
    repeat with proc in procs
        try
            if exists (window 1 of proc) then
                repeat with w in windows of proc
                        copy w's name to the end of windowName
                end repeat
            end if
        end try -- ignore errors
    end repeat
end tell
return windowName

我尝试了重点属性:

copy w's focused to the end of windowName

和选定的属性:

copy w's selected to the end of windowName

但这不起作用!

感谢您的帮助!

推荐答案

在 Mac OS X 10.6 (AppleScript 2.1.2) 上的 windowdescription 属性application process(在System Events'术语中)是 "dialog" 如果窗口是小型化的(在 Dock 中),以及一些其他值(例如标准窗口",但如果它不是小型化的,则可能会有所不同,具体取决于应用程序.

On Mac OS X 10.6 (AppleScript 2.1.2) the description property of a window of an application process (in System Events' terms) is "dialog" if the window is miniaturized (in the Dock), and some other value (such as "standard window", but can be something different depending on the application) if it's not miniaturized.

当一个应用程序完全隐藏时(使用cmd+H或应用程序菜单中的隐藏"命令),它的所有窗口 将被隐藏,无论它们是否被小型化,因此要找出它是否被隐藏,请使用

When an application is hidden altogether (using cmd+H or the "Hide" command from the application's menu), all of its windows will be hidden, regardless of whether they were miniaturized or not, so to find out whether it's hidden, use

visible of application process "<ProcessName>"

当应用程序被隐藏时它是 false.要取消隐藏它,请将该属性设置为 true.

It's false when the application is hidden. To un-hide it, set that property to true.

要找出应用程序的哪个窗口当前处于焦点(最前面/活动),请使用

To find out which window of an application is currently focused (frontmost/active), use

window 1 of application process "<ProcessName>"

应用程序的窗口列表(由应用进程的窗口...返回)按垂直堆栈排序:最前面的窗口在第一个,后面的一个在第二个,依此类推

The list of windows of an application (returned by windows of application process...) is ordered by the vertical stack: the frontmost window is first, the one behind it is second, and so on.

由于在 OS X 中一次只有一个应用程序在最前面,而只有一个窗口在前台,因此您将获得当前聚焦的窗口,如下所示:

Since in OS X only one application is frontmost at a time, and only one window is in the foreground, you'll get at the currently focused window like this:

window 1 of (first application process whose frontmost is true) 

这篇关于Applescript - 获取窗口状态(可见或在 Dock 中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆