1

I am getting following error for the script below. Please help

error "System Events got an error: Can’t get menu bar item \"File\" of process \"iTunes\"." number -1728 from menu bar item "File" of process "iTunes"

Script I wrote

tell application "iTunes"
 activate
 tell application "System Events"
    tell process "iTunes"
        click menu item "Sync \"iPhone\"" of menu item "Devices" of menu bar item "File"
    end tell
 end tell
end tell
1

This works for me to sync my iPhone in iTunes:

tell application "iTunes"
    activate
    delay 1
    tell application "System Events"
        click menu item 1 of menu 1 of menu item "Devices" of menu 1 of menu bar item "File" of menu bar 1 of application process "iTunes"
    end tell
end tell
  • click menu item 1 can also be e.g., click menu item "Sync “Iam’s iPhone”"

  • Note that the value of the delay command(s) may need to be adjusted for your system, and or additional delay commands may or may not be needed. Adjust values of and or add/remove the delay commands as appropriate.


Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .