by -=Pc=- (1 Submission)
Category: Miscellaneous
Compatability: VB Script
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating:
(3 Votes)
This Function gets the current winamp song. I got tired of people iming me asking for this and me redoing it each time.
Option Explicit
'To Use Just Do
'Call MsgBox(GetSong)
'And it will popup a message box with the song.
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function GetSong() As String
Dim WinampCaption As String
Dim CaptionLength As Long
Dim Winamp As Long
Winamp& = FindWindow("Winamp v1.x", vbNullString)
CaptionLength& = GetWindowTextLength(Winamp&)
WinampCaption$ = String$(CaptionLength&, 0)
Call GetWindowText(Winamp&, WinampCaption$, (CaptionLength& + 1&))
If WinampCaption <> "" Then
GetSong = WinampCaption
Else
GetSong = "Error"
End If
End Function