Double Menus

One user requested that more menus and buttons be available on the script editor.  Instead of adding more menus and buttons, this script shows how to double up assignments so that each menu can be used for two purposes.

procedure ChangeCharts(s: string);
var
  i: integer;
  f,p: TForm;
begin
  window:=1; p:=Self;
  for i:=0 to pred(MDIChildCount) do begin
    f:=ActiveMDIChild;
    if Copy(f.name,1,8)='frmChart' then SendKeys(s);
    application.processmessages;
    p.Next;
  end;
end;

begin
  if KeyDown(2) then begin    {test right mouse button down}
    if who=1 then ChangeCharts('1');
    if who=5 then ChangeCharts('5');
  end
  else begin
    if who=1 then ChangeCharts('T');
    if who=5 then ChangeCharts('2');
  end;
end;

The KeyDown(2) function tests whether the right mouse button is depressed when the script executes.   If the right mouse is depressed, the first set of values 1 and 5 are used as parameters.   If the right mouse button is not depressed, the second set of values T and 2 are used as parameters.    This is a slick trick for doubling the functionality of the menu numbers.   The left mouse button is still clicked on the menu to make a selection, and the right mouse is either depressed or not depressed during the left mouse button click.  Thus, both selection choices can be accomplished with one hand using the mouse.  This process works best with the menu numbers 0 through 9 that appear on the main menu when the script editor form is open (could be minimized).