Return to Snippet

Revision: 43323
at March 22, 2011 02:04 by brandonjp


Initial Code
-- brandonjp 201103211103
-- applescript function to check if a menu item exists, if so click on it, then cmd+tab back to previous app

menuItemClick({"timeEdition", "Extras", "Start Recording"})


on menuItemClick({appName, menuName1, menuItem1})
	
	tell application "System Events"
		
		tell application process appName
			
			if menu item menuItem1 of menu 1 of menu bar item menuName1 of menu bar 1 exists then
				
				set frontmost to true
				click menu item menuItem1 of menu 1 of menu bar item menuName1 of menu bar 1
				keystroke tab using {command down}
				
			else
				
				return false
				
			end if
			
		end tell
		
	end tell
	
end menuItemClick

Initial URL


Initial Description


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

Initial Tags
function

Initial Language
AppleScript