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

  1. EXTPROC CEnvi2
  2. /*****************************************************************
  3.  *** HideTask.cmd - CEnvi2 program to hide a task from the task ***
  4.  *** ver.1          list based on task-list name.              ***
  5.  *****************************************************************/
  6.  
  7. #include <PMdll.lib>
  8.  
  9. main(argc,argv)
  10. {
  11.    if ( argc != 2 ) {
  12.       Instructions();
  13.    } else {
  14.       TaskListName = argv[1];
  15.       NameLen = strlen(TaskListName);
  16.       // build list of all window switch titles
  17.       SwitchList = WinQuerySwitchList(Info().hab);
  18.  
  19.       // for each entry, if it matches TaskListName then remove
  20.       // it from the switch list
  21.       assert( SwitchList != NULL );
  22.       SwitchCount = 1 + GetArraySpan(SwitchList);
  23.       HideCount = 0;
  24.       for ( i = 0; i < SwitchCount; i++ ) {
  25.          if ( 0 == WinQuerySwitchEntry(SwitchList[i],SwEntry)
  26.            && !strncmpi(SwEntry.title,TaskListName,NameLen) ) {
  27.             // this task matches input, so remove it
  28.             printf("Remove entry \"%s\"\n",SwEntry.title);
  29.             WinRemoveSwitchEntry(SwitchList[i]);
  30.             HideCount++;
  31.          }
  32.       }
  33.       if ( 0 == HideCount )
  34.          printf("\n\aNo entries for \"%s\" to hide\n",TaskListName);
  35.    }
  36. }
  37.  
  38. WinRemoveSwitchEntry(pSwitchSwitch)
  39. {
  40.    #define ORD_WIN32REMOVESWITCHENTRY  129
  41.    PMDynamicLink("PMSHAPI",ORD_WIN32REMOVESWITCHENTRY,BIT32,CDECL,
  42.                  pSwitchSwitch);
  43. }
  44.  
  45. Instructions()
  46. {
  47.    puts(``)
  48.    puts(`HideTask - Hide task from the task list.`)
  49.    puts(``)
  50.    puts(`SYNTAX: HideTask <TaskName>`)
  51.    puts(``)
  52.    puts(`Where:  <TaskName> - Partial Name from switch list`)
  53.    puts(``)
  54.    puts(`Example: HideTask "MyApp - C:\Goober`)
  55.    puts(``)
  56.    puts(`Note: TaskName matches any switch entry for the`)
  57.    puts(`      length of TaskName and is case-insensitive.`)
  58.    puts(`      Switch entries, if not the same as in the`)
  59.    puts(`      Task List window, are found with WINLIST.CMD`)
  60.    puts(``)
  61. }
  62.  
  63.