Menus And Menu Items

I’m new to Applescript, and I’m trying to work with menus and menu items. Is it possible to add/delete/change menus and menu items for any application like TextEdit for example? Nothing I’ve tried with make new menu seems to work as I get script errors, but I can select a menu item and click it. First, I just need to know if this is possible through AppleScript. If so, any sample code to manipulate TextEdit would be great. If not, is there some other mechanism like InsertMenuItem in the Windows API?

Thanks

– Paul

Hi Paul,

welcome :slight_smile:

Quick answer: No, it isn’t possible.

Stefan,

Thanks for the quick reply. Do you know of an API function like InsertMenuItem with the OS X API?

Thanks

– Paul

This would be my best guess: initWithTitle:action:keyEquivalent:

You wouldn’t use that in an AppleScript, though.

Not sure what your ultimate aim is, Paul - and you may have already considered this as an alternative. However, since it’s sometimes overlooked, I’ll just mention Script Menu, anyway. The use of script folders makes it pretty customisable “ and an Application Scripts Folder means that scripts specific to the frontmost application can be displayed. One can then place scripts (or other files/aliases) in the appropriate folders to trigger a variety of actions from the menu.

Script Menu can be installed using the AppleScript Utility (/Applications/AppleScript/AppleScript Utility.app).

I appreciate everyone’s prompt feedback, as it has been very helpful. Kai, my goal is to add a custom menu to an existing application like TextEdit. I can do it in Windows, and I thought I might be able to use AppleScript, but it looks like I’ll have to try something else. As Bruce suggested, I’ll probably have to dig into an API somewhere. I’m hoping I can use .NET on Windows and Mono on the Mac to make it somewhat portable, but I’m not sure at this point. Thanks

– Paul