Applescript - check if a menu item exists, if so click on it, then cmd+tab back to previous app


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



Copy this code and paste it in your HTML
  1. -- brandonjp 201103211103
  2. -- applescript function to check if a menu item exists, if so click on it, then cmd+tab back to previous app
  3.  
  4. menuItemClick({"timeEdition", "Extras", "Start Recording"})
  5.  
  6.  
  7. on menuItemClick({appName, menuName1, menuItem1})
  8.  
  9. tell application "System Events"
  10.  
  11. tell application process appName
  12.  
  13. if menu item menuItem1 of menu 1 of menu bar item menuName1 of menu bar 1 exists then
  14.  
  15. set frontmost to true
  16. click menu item menuItem1 of menu 1 of menu bar item menuName1 of menu bar 1
  17. keystroke tab using {command down}
  18.  
  19. else
  20.  
  21. return false
  22.  
  23. end if
  24.  
  25. end tell
  26.  
  27. end tell
  28.  
  29. end menuItemClick

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.