Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to press a button in TeamSpeak using applescript, here is my code:

tell application "TeamSpeak 3 Client" to activate
tell application "System Events"
    tell process "TeamSpeak 3"
        click menu item "Connect" of menu "Connections" of menu bar 1
        delay 2
        click button "Connect"
    end tell
end tell

and here is an image of me hovering over the button in accessibility inspector

Accessibility Inspector inspecting a push button

All I want to be able to do is figure out how to push my button using the information given to me in Accessibility Inspector, but with my code I get the error "System Events got an error: Can’t get button "Connect" of process "TeamSpeak 3"." Here is a screenshot of the window the button is directly inside:

enter image description here

share|improve this question
There is UI Browser tool which allow to figure our the GUI hierarchy, so it's easier to track the buttons. See related SE post. – kenorb May 5 '15 at 22:49

You also need to specify the parent objects.

activate application "TeamSpeak 3 Client"
tell application "System Events" to tell process "TeamSpeak 3"
    click menu item "Connect" of menu "Connections" of menu bar 1
    click button "Connect" of window 1 of window 1
end tell
locked by bmike Aug 12 '14 at 18:37

This post has been locked due to the high amount of off-topic comments generated. For extended discussions, please use chat.

Thanks so much for your help! How do you know what window 1 is and menu bar 1 though, for instance, how do you know it's 1 when it could be window 2? Does it say so in the inspector? – user309641 Jun 4 '12 at 18:33
No, but you just have to guess (or run UI elements of window 1, UI elements of window 1 of window 1, etc). – user495470 Jun 4 '12 at 18:43
@user309641 If you know the title of the window you want to click the button in, you can loop through all the windows until you find the one with the correct title. – CajunLuke Jun 4 '12 at 19:14
@CajunLuke really? I'd love to learn how to do something like that. I'm going to need to start learning more about AppleScript! – user309641 Jun 5 '12 at 1:05
For some reason spammers are vandalizing this post. Flag it if anyone has a burning desire to edit / comment on it further. – bmike Aug 12 '14 at 18:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.