Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 1st June 2002, 20:51   #1
RogueProtoKol
Junior Member
 
Join Date: Jun 2002
Posts: 5
gettin winamp window title

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Private Sub Form_Load()
Dim hwndWinamp As Long
hwndWinamp = FindWindow("Winamp v1.x", vbNullString)

sWindowText = Space(255)
r = GetWindowText(hwndWinamp, sWindowText, 255)
sWindowText = Left(sWindowText, r)

MsgBox sWindowText
End Sub

-------------------------------------------
thats the code i have atm, as far as i can see
that *should* fill swindowtext with the winamp
window title... but it doesn't, i end up with
the length of the title in spaces... but not the title!!

what am i doing wrong ?
RogueProtoKol is offline   Reply With Quote
Old 4th June 2002, 16:06   #2
Kaboon
Moderator
 
Kaboon's Avatar
 
Join Date: Jun 2000
Location: Netherlands
Posts: 2,485
Send a message via ICQ to Kaboon
I think that you are looking for a returned version number?

code:

Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Private hwndWinamp As Long

Const WM_USER = &H400

Private Sub Form_Load()

Dim VersionNum As Long
Dim ReturnVersion As String
hwndWinamp = FindWindow("Winamp v1.x", 0)
VersionNumber = SendMessage(hwndWinamp, WM_USER, 0, 0)

If Len(Hex(VersionNumber)) > 3 Then
ReturnVersion = Left(Hex(VersionNumber), 1) & "."
ReturnVersion = ReturnVersion & Mid(Hex(VersionNumber), 2, 1)
ReturnVersion = ReturnVersion & Right$(Hex(VersionNumber), Len(Hex(VersionNumber)) - 3)
MsgBox ("Winamp " & ReturnVersion)
Else
MsgBox "Unknown version"
End If

End Sub



I hope that you can use this. Just copy/paste into an empty form.
Kaboon is offline   Reply With Quote
Old 5th June 2002, 07:39   #3
RogueProtoKol
Junior Member
 
Join Date: Jun 2002
Posts: 5
no, i want the window title which will include the current playing track
RogueProtoKol is offline   Reply With Quote
Old 5th June 2002, 12:23   #4
Kaboon
Moderator
 
Kaboon's Avatar
 
Join Date: Jun 2000
Location: Netherlands
Posts: 2,485
Send a message via ICQ to Kaboon
Well I guess that you could try this code:

code:

' API call's
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Function RunningWinampTitle(lHandle As Long) As String

' This function get's the song
Dim lRet As Long
Dim sTitle As String * 256

lRet = GetWindowText(lHandle, sTitle, Len(sTitle))
RunningWinampTitle = Left(sTitle, InStr(1, sTitle, vbNullChar, vbTextCompare) - 10)

End Function

Private Sub Form_Load()

' Find winamp window
Dim hwndWinamp As Long
hwndWinamp = FindWindow("Winamp v1.x", vbNullString)

' Promt title
MsgBox RunningWinampTitle(hwndWinamp)

End Sub


Just copy and past it into a form again. It should work!
Kaboon is offline   Reply With Quote
Old 15th June 2002, 14:18   #5
RogueProtoKol
Junior Member
 
Join Date: Jun 2002
Posts: 5
thx, sorry for the late reply but ive been busy, the code worked straight away
RogueProtoKol is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump