• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: trigger menu item in contextual menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trigger menu item in contextual menu


  • Subject: Re: trigger menu item in contextual menu
  • From: Alex Zavatone <email@hidden>
  • Date: Tue, 03 Aug 2010 10:00:53 -0500

Here's my sample code using Jacob Rus's awesome Menu_Click routines.

on run
tell application "Director MX" to activate
menu_click({"Director MX", "Xtras", "Update Movies..."})
tell application "System Events"


set myProcesses to the name of every process as list


-- menu_click({"Director MX", "Window", "Message"})
tell process "Director MX"
click button "OK" of window "Update Movies"
end tell
end tell
end run


-- `menu_click`, by Jacob Rus, September 2006
-- 
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item.  In this case, assuming the Finder 
-- is the active application, arranging the frontmost folder by date.

on menu_click(mList)
local appName, topMenu, r


-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"


-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)


-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click

on menu_click_recurse(mList, parentObject)
local f, r


-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)


-- either actually click the menu item, or recurse again
tell application "System Events"
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >trigger menu item in contextual menu (From: KOENIG Yvan <email@hidden>)
 >Re: trigger menu item in contextual menu (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: can this be simplified?
  • Next by Date: Re: can this be simplified?
  • Previous by thread: Re: trigger menu item in contextual menu
  • Next by thread: Active Protocols
  • Index(es):
    • Date
    • Thread