Applescript function to check if an application menu item exists


/ Published in: AppleScript
Save to your folder(s)

only handles one sublevel for the menu


Copy this code and paste it in your HTML
  1. -- brandonjp 201103211048
  2. -- applescript function to check if a menu item exists?
  3. -- returns true or false
  4.  
  5. if menuItemExists({"timeEdition", "Extras", "Start Recording"}) then
  6. display dialog "hoda"
  7. end if
  8.  
  9.  
  10. on menuItemExists({appName, menuName1, menuItem1})
  11.  
  12. tell application "System Events"
  13.  
  14. tell application process appName
  15.  
  16. if menu item menuItem1 of menu 1 of menu bar item menuName1 of menu bar 1 exists then
  17. return true
  18. else
  19. return false
  20. end if
  21.  
  22. end tell
  23.  
  24. end tell
  25.  
  26. end menuItemExists

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.