vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Schützen Sie Ihre Software vor Software-Piraterie - mit sevLock 1.0 DLL!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB & Windows API
FindWindow + SendMessage 
Autor: basdo x3
Datum: 25.04.08 19:37

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 Class
Findet 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
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
FindWindow + SendMessage2.513basdo x325.04.08 19:37
Re: FindWindow + SendMessage1.418ModeratorMartoeng25.04.08 19:51
Re: FindWindow + SendMessage1.403basdo x325.04.08 20:20
Re: FindWindow + SendMessage2.392basdo x326.04.08 16:19
Re: FindWindow + SendMessage1.726ModeratorMartoeng27.04.08 21:22

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel