Applescript problem...

Discuss the current and future development of Max.
Post Reply
neil.baldwin
Posts: 23
Joined: Sun May 13, 2007 9:58 pm

Applescript problem...

Post by neil.baldwin » Sun Apr 06, 2008 2:26 pm

Related to my other two posts, I thought a possible solution would be to modify the iTunes Meta Data script so that it

- selects each track as it grabs the info from iTunes, leaving you with all the tracks selected and able to just Apple+Enter to encode the disc
- opens the "Download Album Art" menu

The first bit works but I can't get the "Download Album Art" menu to open. Here is the snippet of Applescript that I'm using. It uses a function that I found on the internet called "menu_click" which gives you a simpler way of accessing applications menu hierarchy. I tried the same scripting method to operate menu items in Safari (as a test) and it works fine so the function seems to be OK.


tell application "Max" to activate
menu_click({"Max", "Tools", "Download Album Art..."})


-- `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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest