Projects

Find all our projects in development below.
All source code is GNU General Public License (GPL)

Gateway Multi-function Keyboard Utility

Browsing Utility/WinampMod.bas (3.61 KB)

Attribute VB_Name = "WinampMod"

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 Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_COMMAND = &H111
Private Const WM_USER = &H400

Public Function WAGetSongTitle() As String
Dim strBuffer As String, strBufferLen As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    strBufferLen = GetWindowTextLength(WAHandle)
    strBuffer = String(strBufferLen, 0)
    GetWindowText WAHandle, strBuffer, strBufferLen + 1
    If InStr(strBuffer, vbNullChar) Then strBuffer = Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
    If InStr(strBuffer, "-") Then strBuffer = Left(strBuffer, InStrRev(strBuffer, "-") - 1)
    WAGetSongTitle = Trim(strBuffer)
End Function


Public Function WAVolRaise() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WAVolRaise = PostMessage(WAHandle, WM_COMMAND, 40058, 0&)
End Function

Public Function WAVolLower() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WAVolLower = PostMessage(WAHandle, WM_COMMAND, 40059, 0&)
End Function
Private Function GetWinampHandle() As Long
    GetWinampHandle = FindWindow("Winamp v1.x", vbNullString)
End Function

Public Function WATrackPrev() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackPrev = PostMessage(WAHandle, WM_COMMAND, 40044, 0&)
End Function

Public Function WATrackNext() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackNext = PostMessage(WAHandle, WM_COMMAND, 40048, 0&)
End Function

Public Function WATrackPlay() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackPlay = PostMessage(WAHandle, WM_COMMAND, 40045, 0&)
End Function

Public Function WATrackFForward() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackFForward = PostMessage(WAHandle, WM_COMMAND, 40148, 0&)
End Function

Public Function WATrackFRewind() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackFRewind = PostMessage(WAHandle, WM_COMMAND, 40144, 0&)
End Function

Public Function WATrackPause() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackPause = PostMessage(WAHandle, WM_COMMAND, 40046, 0&)
End Function

Public Function WATrackStop() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WATrackStop = PostMessage(WAHandle, WM_COMMAND, 40047, 0&)
End Function

Public Function WAPlaybackStatus() As Long
Dim WAHandle As Long
    WAHandle = GetWinampHandle
    If WAHandle = 0 Then Exit Function
    WAPlaybackStatus = SendMessageLong(WAHandle, WM_USER, 0, 104)
End Function

Download Utility/WinampMod.bas

Back to file list


Back to project page