n' Abend
Mein Code:
Public Class Form1
Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As _
EnumWindowsProc, ByVal lParam As Int32) As Int32
Public Declare Function IsWindowVisible Lib "user32.dll" (ByVal hwnd As _
IntPtr) As Boolean
Public Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam _
As Int32) As Boolean
Public Declare Function GetWindowText Lib "user32.dll" Alias _
"GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch _
As Int32) As Int32
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias _
"GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Int32
Public Declare Function GetWindowLong Lib "user32.dll" Alias _
"GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Int32) As Int32
Public Declare Function GetParent Lib "user32.dll" (ByVal intptr As IntPtr) _
As IntPtr
Public Const GWL_HWNDPARENT As Int32 = -8
Private newwindowlist As List(Of String)
Declare Function SendMessage Lib "user32.dll" _
Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal Msg As Long)
Private Function EnumWinProc(ByVal hwnd As IntPtr, ByVal lParam As Int32) _
As Boolean
If IsWindowVisible(hwnd) Then
If GetParent(hwnd) = IntPtr.Zero Then
If GetWindowLong(hwnd, GWL_HWNDPARENT) = 0 Then
Dim str As String = String.Empty.PadLeft( _
GetWindowTextLength(hwnd) + 1)
GetWindowText(hwnd, str, str.Length)
If Not String.IsNullOrEmpty(str.Substring(0, str.Length - _
1)) Then newwindowlist.Add(str.Substring(0, str.Length - _
1))
End If
End If
End If
EnumWinProc = True
End Function
Private Sub RefreshWindowList()
newwindowlist = New List(Of String)
EnumWindows(AddressOf EnumWinProc, CInt(True))
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
RefreshWindowList()
For Each item As String In newwindowlist
If item.EndsWith(" - Chat") Then 'nach dem Channel Fenster suchen
ListBox1.Items.Add(item)
End If
Next
End Sub
Private Sub Button1_Click() 'Liste erneuern
RefreshWindowList()
For Each item As String In newwindowlist
If item.EndsWith(" - Chat") Then 'nach dem Channel Fenster suchen
ListBox1.Items.Add(item)
End If
Next
End Sub
End ClassFindet schonmal die Fenster mit dem Namen " - Chat" am Ende, ich hab bloß keine Ahnung wie ich etwas in das Ausgewählte Fenster sende? Ich weiß zwar, das ich es mit der SendMessage Funktion machen muss, bin jdeoch jedesmal gescheitert.
Hätte jemand ein Sample/Codeauschnitt?
Mfg
Basdo |