Hi,
If you haven't already done so, you could try searching in the MACSCRPT mailing list (available via
Dartmouth's MACSCRPT Hub), or in any of the other resources listed in the
New to AppleScript topic in this Forum. I myself don't believe that it's possible to script contextual menu item selections through AppleScript, at least not in current versions of the Mac OS. Such menus are not only modal but also dynamic (built "on the fly"), and controlling them would probably require patching the system's contextual menu manager (CMM) routines.
On the other hand, if I remember rightly, older versions of the Title Free extension allowed you to use keystroke-combinations to activate its features; this latter task is easily handled by AppleScript with the help of third-party scripting additions (OSAXen). If the latest version of Title Free no longer accepts key-stroke-combinations, and the extension isn't directly scriptable, you may have better luck with a third-party control panel or extension (perhaps QuicKeys?) that can select menu items from modal dynamic menus (similarly to how 'Okey Dokey Pro' can auto-select buttons in modal dialogs).
Just to clarify a little... In AppleScript, it's fairly easy to *display* a contextual menu by simulating a control-click, via a third-party scripting addition (OSAX) such as
Sändi's Additions (
MouseClick At {x, y} with Control) or
Akua Sweets (
input state {pointer location:{x, y}, button down:true, control key bit:true}). However, it's not so easy to then *select* a menu item from the contextual menu. The stumbling block is that the menu display is usually modal, and the host app (such as the Finder) doesn't get a chance to respond to further script commands that try to select a menu item.
For instance, here's a short script that uses the Sändi's Additions OSAX. The script first displays the contextual menu for my startup disk in the Finder (this works well), and then tries to select the second menu item (usually 'Open') from the contextual menu (this fails miserably):-
Code:
tell application "Finder"
-- Bring the app frontmost, to accept clicks
activate
-- Control-click on the startup-disk icon at the upper-right corner of my desktop, to display a contextual menu
set theItemPos to (position of startup disk) -- Get the upper-left coordinates of the icon bounds
set theItemPos to {((item 1 of theItemPos) + 15), ((item 2 of theItemPos) + 15)} -- Adjust to icon's center
MouseClick At theItemPos with Control -- Simulate a control-click on the icon
-- Try to select the second menu item (usually, 'Open'), from the contextual menu displayed to the icon's left
-- //NOTE: THIS DOES NOT WORK! (The contextual menu display is modal)
set theCMMMenuItemPos to {((item 1 of theItemPos) - 30), ((item 2 of theItemPos) + 5)}
MouseClick At theCMMMenuItemPos
end tell
Actually, I'd be very interested to hear of any AppleScript workarounds for this issue. [Some non-AppleScript solutions that worked in the past were provided by control panels or extensions such as
Respond! or
Menu Tasker, which allowed "multi-tasking" for modal menus, but these no longer work with Mac OS 8.5 or later.]
Regards,
--Paul
[This message has been edited by Paul Crawford (edited 05-07-2000).]