AppleScript instruction to set webcam in FaceTime

322 Views Asked by At

I need to automate a FaceTime call using AppleScript, but one of my requirements is to pick a specific webcam. I am trying to use this code:

tell application "System Events"
tell process "FaceTime"
    tell menu bar 1
        tell menu bar item "Video"
             click menu item "Webcam 520X"
        end tell
    end tell
end tell
end tell

But I got this error message:

System Events got an error: Can’t get menu item "Webcam 520X" of menu bar item "Video" of menu bar 1 of process "FaceTime".

Any suggestion about how to do it in the right way? Thanks!

1

There are 1 best solutions below

0
On

There is always a menu reference between the menu item and its menu bar item

activate application "FaceTime"
tell application "System Events"
    tell process "FaceTime"
        tell menu bar 1
            tell menu bar item "Video"
                tell menu 1
                    click menu item "Webcam 520X"
                end tell
            end tell
        end tell
    end tell
end tell

or

activate application "FaceTime"
tell application "System Events"
    tell process "FaceTime"
        click menu item "Webcam 520X" of menu 1 of menu bar item "Video" of menu bar 1
    end tell
end tell