MenuScripter is a derivation of 7Edit, a factored text editing sample code application. It has been designed to show how to use the features of the OSA from within your application. As the name implies, many of the menu commands are implemented using scripts instead of hard coding. In many cases the hard coding will also be found within SVAppleEvents.c, but it does not get called if a script to do the same is found.
Later these hard coded commands may go, but for now they provide a contrast between the two methods of implementation.
To use MenuScripter you must the AppleScript system extension installed.
Scripts are stored in two representations :
'Scpt' - a compiled script extracted from the AppleScript component with OSAStore and saved as a resource.
'SCPT' - a raw textual script.
Menu scripts are stored as resources with ID equal to theMenuID*32 + the item number within the menu. A script works for the whole menu if it has a resource id of 32*theMenuID.
MenuScripter does not only allow the use a scripts to drive menus, it also allows them to be edited. To edit the script for a menu simply hold control and option down as you select a menu item, and you will be presented with a dialog allowing editing of the script.
Using control-option while selecting a menu item in order to get at a script does not always work the first time you try it, and it just does the command. Persevere - you'll get there. If it *really* can't get the script, MenuScripter will beep at you.