【发布时间】:2011-10-25 22:31:52
【问题描述】:
使用 AppleScript 我想在多台机器上自动创建新用户帐户。我正在尝试使用 UI 脚本,但似乎无法在 iChat 帐户首选项窗口中的“添加帐户”(+) 按钮上执行单击命令。我尝试使用 Accessibility Inspector.app 来推断按钮的名称,但我似乎仍然无法通过 AppleScript 访问它。
根据 Accessibility Inspector.app,该按钮具有以下属性:
AXRole: AXButton
AXRoleDescription: button
AXHelp: <nil>
AXEnabled: YES
AXFocused (W): NO
AXParent: <AXGroup>
AXWindow: <AXWindow:AXStandardWindow>
AXTopLevelUIElement: <AXWindow:AXStandardWindow>
AXPosition: x=225.00 y=462.00
AXSize: w=23.00 h=22.00
AXTitle: <empty string>
AXIdentifier: _NS:27
AXDescription: Add Account
这是一个示例启动 AppleScript,可让您进入 Accounts Preference 窗口:
tell application "iChat"
activate
tell application "System Events"
tell process "iChat"
tell menu bar 1
click menu item "Preferences…" of menu "iChat"
end tell
click button "Accounts" of tool bar 1 of window 1
click button "Add Account" of window "Accounts"
end tell
end tell
end tell
请注意,第 9 行是我正在尝试的工作。您将在下面找到指向 iChat 帐户首选项窗口屏幕截图的链接,其中箭头指向我尝试访问的按钮。另请注意,我知道我可以使用“按键选项卡”来访问(+)按钮,但这并不总是有效,因为您必须按下选项卡的次数会根据您已经创建的帐户类型而变化iChat。
【问题讨论】:
标签: applescript