2011-10-25 12 views
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。

iChat Account Preferences Window

答えて

2

ような場合には、あなただけのアイテム番号を使用することができますので、すべてのUIオブジェクトは、タイトルを持っていない - あなたはインスペクタウィンドウに表示される階層全体を含める必要があることに注意を。

tell application "iChat" 
    activate 
    tell application "System Events" 
     tell process "iChat" 
      tell menu bar 1 to click menu item "Preferences…" of menu "iChat" 
      delay 0.5 
      tell window 1 
       click button "Accounts" of tool bar 1 
       delay 0.5 
       click button 1 of group 1 of group 1 
      end tell 
     end tell 
    end tell 
end tell 
+0

これはトリックでした。ありがとう! – psyrendust

関連する問題