REM    _____________________________________________________
REM   |\___________________________________________________/| 
REM   | |                                                 | |
REM   | | SOURCE TITLE:    GT-API_GetTaskBarWindows       | |
REM   | | ------------                                    | |
REM   | | SOURCE AUTHOR:   Garrett R. Hylltun             | |
REM   | | -------------                                   | |
REM   | | DATE:            14 December, 2003              | |
REM   | | ----                                            | |
REM   | | REQUIREMENTS:    VDS 5.x                        | |
REM   | | ------------                                    | |
REM   | | SOURCE STATUS:   Public Domain                  | |
REM   | | -------------                                   | |
REM   | | SOURCE DESCRIPTION:                             | |
REM   | | ------------------                              | |
REM   | |   Example showing how to get a list of all open | |
REM   | | windows like the taskbar, with a little help    | |
REM   | | from some api calls.                            | |
REM   | |                                                 | |
REM   | |   The use of this script and calling dlls is at | |
REM   | | your own risk and you agree that the authors of | |
REM   | | this code will not be held responsible for any  | |
REM   | | damages in any form that may or may not occur   | |
REM   | | from the use of this information or code.       | |
REM   | |_________________________________________________| |
REM   |/___________________________________________________\|

  OPTION FIELDSEP,|
  DIALOG CREATE,Task Entries,0,0,140,200,CLASS TASKENTRIESPROGRAM1,SMALLCAP,ONTOP
  DIALOG ADD,STYLE,STYLE1,Arial,8,,BACKGROUND,FOREGROUND
  DIALOG ADD,LIST,LIST1,0,0,140,200,,,STYLE1
  DIALOG SHOW
  %A = @sendmsg(@winexists(~LIST1),$0194,600,0)
  LIST CREATE,1
  LIST CREATE,2
  LIST WINLIST,1,ICN
  %L = 2
  IF @text(1)
    LOADLIB USER32.DLL
    LIST SEEK,1,0
    REPEAT
      PARSE "%A;%B;%C",@item(1)
REM   --- |-------------------------------------------------| ---
REM   --- | First, we eliminate all windows that have no    | ---
REM   --- | title bar text.  We do this by checking if %C   | ---
REM   --- | has anything in it.  If it does, then we keep   | ---
REM   --- | going.                                          | ---
REM   --- |-------------------------------------------------| ---
      IF %C
        %%tWinWide = @winpos(%A,W)
        %%tWinHigh = @winpos(%A,H)
        %%TestDimensions = @sum(%%tWinWide,%%tWinHigh)
REM   --- |-------------------------------------------------| ---
REM   --- | Then we eliminate all windows that have no      | ---
REM   --- | width or height.  If a window does have some    | ---
REM   --- | width and height to it, then we keep going.     | ---
REM   --- |-------------------------------------------------| ---
        IF @greater(%%TestDimensions,1)
          %H = @strdel(%A,1,1)
          %I = @lib(user32,IsWindow,BOOL:,%H)
REM   --- |-------------------------------------------------| ---
REM   --- | Then we eliminate all windows that are not      | ---
REM   --- | windows at all.  We us an api call for this.    | ---
REM   --- | If it is a window, then we keep going.          | ---
REM   --- |-------------------------------------------------| ---
          IF @greater(%I,0)
            %I = @lib(user32,IsWindowVisible,INT:,%H)
REM   --- |-------------------------------------------------| ---
REM   --- | Then we eliminate all windows that are not      | ---
REM   --- | visible windows.  We us an api call for this.   | ---
REM   --- | If it is a visible window, then we keep going.  | ---
REM   --- |-------------------------------------------------| ---
            IF @greater(%I,0)
REM   --- |-------------------------------------------------| ---
REM   --- | We now have all the possible windows that would | ---
REM   --- | be listed on the taskbar.  Except we need to    | ---
REM   --- | dump the Program Manager since we normally do   | ---
REM   --- | not see it on the task bar.   And then we are   | ---
REM   --- | left with windows that would typically be seen  | ---
REM   --- | on the windows taskbar.                         | ---
REM   --- |-------------------------------------------------| ---
              IF @unequal(%C,Program Manager)
                LIST ADD,2,@item(1)
                LIST ADD,LIST1,%C
              END
            END
          END
        END
      END
      %D = @next(1)
    UNTIL @null(@item(1))
    FREELIB USER32.DLL
  END


:EVENTLOOP
  WAIT EVENT
  %E = @event()
  IF %E
    GOTO %E
  END
  GOTO EVENTLOOP

:CLOSE
  LIST CLEAR,1
  LIST CLOSE,1
  LIST CLEAR,2
  LIST CLOSE,2
  EXIT
