【发布时间】:2015-10-15 06:28:09
【问题描述】:
我正在寻找访问 applescript 无法访问的 UI 的方法。我知道 applescript 可以访问 UI 元素。但有时我会遇到无法通过 applescript 访问 UI 元素的情况。像下面...
tell application "System Preferences" to activate
delay 1
tell application "System Events"
tell process "System Preferences"
set frontmost to true
click button 22 of scroll area 1 of window 1
delay 1
UI elements of last group of list 1 of window 1
end tell
end tell
这只会返回 2 个 UI 元素 图像 和 静态文本。
{
image 1 of group 3 of list 1 of window "Users & Groups" of application process "System Preferences" of application "System Events",
static text "Login Options" of group 3 of list 1 of window "Users & Groups" of application process "System Preferences" of application "System Events"
}
显然有一个可点击的 UI 元素,它属于以上 2 个元素。因为我可以点击“登录选项”。
幸运的是通过发送keystroke和key code命令被正确接收。
set DownArrow to 125
set UpArrow to 126
tell application "System Preferences" to activate
delay 1
tell application "System Events"
tell process "System Preferences"
set frontmost to true
click button 22 of scroll area 1 of window 1
delay 1
keystroke tab
repeat 3 times
delay 1
key code DownArrow
delay 1
key code UpArrow
end repeat
end tell
end tell
tell application "System Preferences" to quit
我的问题是……
- 为什么 applescript 似乎忽略了“登录选项”UI 元素?
- 为什么我不能用鼠标或触控板点击“登录选项”UI 元素?
- 为什么keystroke和key code命令无法访问“登录选项”UI元素?
- 真的没有办法在不使用keystroke和key code命令的情况下选择“登录选项”UI元素吗?
- 如何访问 applescript 不可访问的 UI 元素?
感谢任何提示。任何代码(python、c、objective-c 等)都更受欢迎。:)
谢谢。
【问题讨论】:
标签: objective-c xcode macos applescript