1
使用AppleScript我想在多臺機器上自動創建新的用戶帳戶。我正在嘗試使用UI腳本,並且似乎無法在「iChat帳戶首選項」窗口的「添加帳戶」(+)按鈕上執行單擊命令。我試圖使用Accessibility Inspector.app來推斷按鈕的名稱,但我仍然無法通過AppleScript訪問它。使用AppleScript在偏好窗口中單擊加號(+)按鈕
根據輔助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,將讓你的帳戶首選項窗口:
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 Account Preferences Window
這沒有把戲。謝謝! – psyrendust