GetWindowText works for windows outside of your application to.
The problem is that you need the windowhandle of that window.
One way of finding this is by using the FindWindow API.
In order to use this function, you need to know either the windowtext (and this is what we don't know) or the windowclass.
Using Spy++ it is easy to find this out. And with Winamp we are lucky. It has an easy to recognize classname.
With the winamp version I'm using this is 'Winamp v1.x', I'm downloading a newer version right now, so I assume the classname will be 'Winamp v2.x' now.
This makes the possibily of two open windows with the same classname not so big.
[Edited by Frans C on 03-21-2000 at 02:27 PM]Code:Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Sub Command1_Click() Dim retVal As Long Dim sTitle As String Dim hWinAmp As Long hWinAmp = FindWindow("Winamp v1.x", vbNullString) If hWinAmp <> 0 Then sTitle = Space(256) retVal = GetWindowText(hWinAmp, sTitle, 255) MsgBox sTitle End If End Sub




Reply With Quote