
Swnd = apiGetWindow(swnd, GW_HWNDPREV) 'Retrieve the previous window 'swnd is a sibling window, so gather or identify it here, don't do anything syncronous in here though. Swnd = apiGetWindow(apiFindWindowEx(pwnd, 0, vbNullString, vbNullString), GW_HWNDLAST) Private Function GetSiblings(ByVal pwnd As Long) As String Private Declare Function apiFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function apiGetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long WindowList.Add(sClass.ToString & ", " & hwnd & ", " & sTitle.Private Declare Function apiIsWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As Long) As Long Private Function EnumWindowProc(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean Public Delegate Function MyDelegateCallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Booleanĭeclare Function EnumWindows Lib "user32" (ByVal x As MyDelegateCallBack, ByVal y As Integer) As Integerĭeclare Auto Function GetClassName Lib "user32" _īyVal lpClassName As, _ĭeclare Auto Function GetWindowText Lib "user32" _ The function getWindowList does the trick. Just create a new module called modEnumWindows in your project and copy this code into it. hopefully this will save someone some time. I searched and struggled for about 2 hours before I was able to put this together. Home : Code : Forums : Submit : Mailing List : About : ContactĪ small module containing all the code you need to do this simple task in vb.net. EnumWindows in vb.net - Visual Basic, VB.NET
