Hello;
Can someone tell me how to retrieve all the 'handles' of all the Windows.
Printable View
Hello;
Can someone tell me how to retrieve all the 'handles' of all the Windows.
I personally haven`t tried this yet. :D
But there is a web site that can help you.
http://www.allapi.net/
Plus, they have an API-Guide (with tons of examples, and a list of API Functions)....
.... and an API-Toolshed, a replacement for VB`s API Viewer utility.
(Download for FREE!)
Here is a start: EnumWindows API Function Call
The EnumWindows function enumerates all top-level windows on the screen by passing the handle of each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.
Search for this function on the site, they have an example.
Add to a Module
now use this line to display them (in the debug window)Code:Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer
iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1
If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
Debug.Print Left(sName, Length - 1)
End If
EnumWindowsProc = 1
End Function
Code:'EnumWindows AddressOf EnumWindowsProc, 0
I prefer the FindWindowEx function. You can use this to enumerate all top level windows, and then plug in each of their handles to enumerate the lower level child windows and so on. Read up on it. I love this function. You can search by class or window name if you so choose, etc.
You can find the child windows but using the EnumChildwindows function.