Private Sub CommandButton1_Click()
Dim ret As Long
Dim hwnd As Long
Dim str As String * 256
ret = GetDesktopWindow()
hwnd = GetWindow(ret, GW_CHILD)
Do While hwnd <> 0
GetWindowText hwnd, str, Len(str)
hwnd = GetWindow(hwnd, GW_HWNDNEXT)
If Left$(str, 1) <> vbNullChar Then
UserForm1.ListBox1.AddItem str
UserForm1.TextBox1.Text = str
End If
Loop
End Sub