home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / DOMENU.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-03  |  3KB  |  67 lines

  1. EXTPROC CEnvi2
  2. /**************************************************************************
  3.  *** DoMenu.cmd - Quick interface to pass menu commands directly.       ***
  4.  *** ver.3        This posts menu command directly to any frame window. ***
  5.  **************************************************************************/
  6.  
  7. #include <MenuCtrl.lib>
  8. #include <WinTools.lib>
  9. #include <OptParms.lib>
  10.  
  11. main(argc,argv)
  12. {
  13.    FullMatch = OptionalParameter(argc,argv,"FULL");
  14.  
  15.    if ( (2 != argc && 3 != argc)  ||  !strcmp(argv[1],"/?")  ||  !strcmpi(argv[1],"help") )
  16.       Instructions();
  17.  
  18.    if ( 2 == argc ) {
  19.       hwnd = GetActiveWindow();
  20.       MenuString = argv[1];
  21.    } else {
  22.       if ( !(hwnd = GetWindowHandle(WindowTitle = argv[1])) ) {
  23.          printf("\aCould not find window \"%s\"\n",WindowTitle);
  24.          exit(EXIT_FAILURE);
  25.       }
  26.       MenuString = argv[2];
  27.    }
  28.    // try regular menu first, then system menu, then anything else
  29.    if ( !MenuCommand(hwnd,FID_MENU,MenuString,True,Dummy,FullMatch)
  30.      && !MenuCommand(hwnd,FID_SYSMENU,MenuString,True,Dummy,FullMatch)
  31.      && !MenuCommand(hwnd,0,MenuString,True,Dummy,FullMatch) ) {
  32.       printf("\aSelection \"%s\" not found in any menu.\n",MenuString);
  33.       exit(EXIT_FAILURE);
  34.    }
  35.    return EXIT_SUCCESS;
  36. }
  37.  
  38.  
  39. Instructions()
  40. {
  41.    puts("\a")
  42.    puts(`DoMenu - Post menu selection to a PM window`)
  43.    puts(``)
  44.    puts(`SYNTAX: DoMenu <WinTitle> <MenuString> [/FULL] `)
  45.    puts(``)
  46.    puts(`Where: WinTitle - Name of a window; if this parameter not supplied then`)
  47.    puts(`                  use currently active window`)
  48.    puts(`       MenuString - Ascii text of menu string to select from any menu.`)
  49.    puts(`                    Will select first match for length of MenuString,`)
  50.    printf("                    case-insensitive`.  If you include the sequence \"%s\"\n",gSubmenuBranch)
  51.    printf("                    then the %s characters specify the sub-menu path to take\n",gSubmenuBranch)
  52.    puts(`       /FULL - With this option, will only accept menu item that matches`)
  53.    puts(`               <MenuString> for the full length of <MenuString>`)
  54.    puts(``)
  55.    puts(`Example: If the calculator is running, this would set font to 18 x 10`)
  56.    puts(`            DoMenu Calculator "18 x 10"`)
  57.    puts(``)
  58.    puts(`Example: If an "OS/2 Window" session is active, to choose "Copy All"`)
  59.    puts(`            DoMenu "Copy All"`)
  60.    puts(`         In E.EXE, to save file use one of the following`)
  61.    puts(`            DoMenu E.EXE Save /FULL`)
  62.    puts(`            DoMenu E.EXE File##Save /FULL`)
  63.    puts(``)
  64.    exit(EXIT_FAILURE);
  65. }
  66.  
  67.