Page 1 of 1

Visible Windows List [Windows]

Posted: Sat Aug 14, 2010 3:06 am
by oryaaaaa

Code: Select all

Structure FindWindowData
  hFW.l ; variable to store a handle
  sFW.s ; variable to store a Window name
  cFW.s ; variable to store a window class name
  px.l
  py.l
  height.l
  width.l
EndStructure

Global NewList FindWindow.FindWindowData()

Procedure.l EnumWindowsProc(hFind, lParam)
  Protected WindowName.s = Space(255)
  Protected WindowClass.s = Space(255)
  Protected WP.WINDOWPLACEMENT
  ClearStructure(@WP, WINDOWPLACEMENT)
  WP\length = SizeOf(WINDOWPLACEMENT)
  If GetWindowText_(hFind, WindowName, 255)
    Result = GetClassName_(hFind, WindowClass, 255)
    ;    If FindString(WindowClass, "WindowClass_", 0)
    If GetWindowPlacement_(hFind, @WP)
      If WP\showCmd=1 And IsWindowVisible_(hFind) And WindowClass<>"Button" And WindowClass<>"Progman"
        AddElement(FindWindow())
        FindWindow()\hFW = hFind
        FindWindow()\sFW = WindowName
        FindWindow()\cFW = WindowClass
        FindWindow()\px    = WP\rcNormalPosition\left
        FindWindow()\py    = WP\rcNormalPosition\top
        FindWindow()\height =  WP\rcNormalPosition\bottom-WP\rcNormalPosition\top-2*GetSystemMetrics_(#SM_CYFRAME)-GetSystemMetrics_(#SM_CYCAPTION)
        FindWindow()\width = WP\rcNormalPosition\right-WP\rcNormalPosition\left-2*GetSystemMetrics_(#SM_CXFRAME)
      EndIf
    EndIf
    ;  EndIf
  EndIf
  ProcedureReturn 1
EndProcedure

If EnumWindows_(@EnumWindowsProc(), 0)
  CallDebugger
EndIf

Re: Visible Windows List [Windows]

Posted: Sat Aug 14, 2010 10:06 pm
by IdeasVacuum
A very nice code example oryaaaaa, thank you for sharing.

Code: Select all

If EnumWindows_(@EnumWindowsProc(), 0)
  
   FirstElement(FindWindow.FindWindowData())
  
         For i = 1 To ListSize(FindWindow.FindWindowData())
    
                 Debug FindWindow.FindWindowData()\sFW
                 Debug FindWindow.FindWindowData()\cFW
                 Debug " "
           
                 NextElement(FindWindow.FindWindowData())

         Next i
EndIf