AppleScript的 - 系统事件错误:辅助设备的访问被禁止 [英] AppleScript - System Events Error : Access for assistive devices is disabled

查看:2078
本文介绍了AppleScript的 - 系统事件错误:辅助设备的访问被禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AppleScript的和系统事件的一个问题。

I have a problem with AppleScript and System Events.

我必须勾选启用辅助设备的访问中的普及preference在系统preferences窗格。

I have check "Enable access for assistive devices" in the "Universal Access" preference pane in System Preferences.

当我尝试:

拱-i386 osascript -e'告诉应用程序系统事件让每一个过程的每一个窗口的位置

arch -i386 osascript -e 'tell application "System Events" to get the position of every window of every process'

我有这样的错误:

系统事件得到了一个错误:辅助设备的访问被禁止。 (-25211)

System Events got an error: Access for assistive devices is disabled. (-25211)

你有什么想法?

非常感谢

推荐答案

问题是不是辅助设备。 AppleScript的似乎错误地返回该错误code,当它试图访问一个过程,不能有任何的窗口窗口(在我的情况,这是谷歌浏览器助手)。

The problem is not the assistive devices. AppleScript seems to incorrectly return that error code when it tries to access windows of a process that can never have any windows (in my case it was "Google Chrome Helper").

您需要捕捉的错误。这对我的作品:

You need to catch the errors. This works for me:

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

返回坐标对,如清单{{1067 22},{31,466},{27,56},{63,22},{987,22}} - 是什么你试图获得?

returning a list of coordinate pairs, such as {{1067, 22}, {31, 466}, {27, 56}, {63, 22}, {987, 22}} – is that what you were trying to get?

这篇关于AppleScript的 - 系统事件错误:辅助设备的访问被禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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