• Welcome to Valhalla Legends Archive.
 

adding winamp to bot

Started by LizArD, July 11, 2004, 03:15 AM

Previous topic - Next topic

Soul Taker

Looks like you're possibly sending some character Bnet doesn't like, since the line break is screwed up.  Maybe you're sending a null in that message?

LizArD

any clue where is it =D?

hismajesty


FrOzeN

heres probably the best way to set out the code..
this doesn't have set volume and stuff but you can add it in using info from the other 3 pages in this topic  :P

put this is a module
Public l_winamp As New Winamp 'Change if not Winamp.cls

put this a a class module (Winamp.cls)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) 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 Const m_Const_Winamp As String = "Winamp v1.x"
Private Const m_WM_COMMAND = &H111
Public Enum Enum_WA_Command
 WA_Previous_track = 40044
 WA_Next_track = 40048
 WA_PLAY = 40045
 WA_Pause_Unpause = 40046
 WA_STOP = 40047
 WA_Fadeout_and_stop = 40147
 WA_Stop_after_current = 40157
 WA_Fast_forward_5_seconds = 40148
 WA_Fast_rewind_5_seconds = 40144
 WA_Start_of_playlist = 40154
 WA_Go_to_end_of_playlist = 40158
 WA_Open_file_dialog = 40029
 WA_Open_URL_dialog = 40155
 WA_Open_file_info_box = 40188
 WA_Set_time_display_mode_to_elapsed = 40037
 WA_Set_time_display_mode_to_remaining = 40038
 WA_Toggle_preferences_screen = 40012
 WA_Open_visualization_options = 40190
 WA_Open_visualization_plug_in_options = 40191
 WA_Execute_current_visualization_plug_in = 40192
 WA_Toggle_about_box = 40041
 WA_Toggle_title_Autoscrolling = 40189
 WA_Toggle_always_on_top = 40019
 WA_Toggle_Windowshade = 40064
 WA_Toggle_Playlist_Windowshade = 40266
 WA_Toggle_doublesize_mode = 40165
 WA_Toggle_EQ = 40036
 WA_Toggle_playlist_editor = 40040
 WA_Toggle_main_window_visible = 40258
 WA_Toggle_minibrowser = 40298
 WA_Toggle_easymove = 40186
 WA_Raise_volume_by_1 = 40058
 WA_Lower_volume_by_1 = 40059
 WA_Toggle_repeat = 40022
 WA_Toggle_shuffle = 40023
 WA_Open_jump_to_time_dialog = 40193
 WA_Open_jump_to_file_dialog = 40194
 WA_Open_skin_selector = 40219
 WA_Configure_current_visualization_plug_in = 40221
 WA_Reload_the_current_skin = 40291
 WA_Close_Winamp = 40001
 WA_Moves_back_10_tracks_in_playlist = 40197
 WA_Show_the_edit_bookmarks = 40320
 WA_Adds_current_track_as_a_bookmark = 40321
 WA_Play_audio_CD = 40323
 WA_Load_a_preset_from_EQ = 40253
 WA_Save_a_preset_to_EQF = 40254
 WA_Opens_load_presets_dialog = 40172
 WA_Opens_auto_load_resets_dialog = 40173
 WA_Load_default_preset = 40174
 WA_Opens_save_preset_dialog = 40175
 WA_Opens_auto_load_save_preset = 40176
 WA_Opens_delete_preset_dialog = 40178
 WA_Opens_delete_an_auto_load_preset_dialog = 40180
End Enum
Public Function IsWinampRunning() As Boolean
 IsWinampRunning = IIf(FindWindow(m_Const_Winamp, vbNullString) = 0, False, True)
End Function

Public Sub Execute(ByVal l_Command As Enum_WA_Command)
 SendMessage FindWindow(m_Const_Winamp, vbNullString), m_WM_COMMAND, l_Command, 0
End Sub

Public Function GetWindowTitle(ByVal WindowTitle As String) As String
   Dim Title As String
   TheHWnd = FindWindow(WindowTitle, vbNullString)
       Title = Space$(GetWindowTextLength(TheHWnd) + 1)
       Call GetWindowText(TheHWnd, Title, Len(Title))
       Title = Left$(Title, Len(Title) - 1)
   GetWindowTitle = Title
End Function


usage.. this would make it play..
If l_winamp.IsWinampRunning Then l_winamp.Execute Enum_WA_Command.WA_PLAY
~ FrOzeN

LizArD

#49
Case "mp3"
       Call clsWinamp.GetTitle
       Send "Mp3: "


Im guessing it should be that, at this point in time it is

Send "Current Title: " & clsWinamp.GetTitle


Public Function GetTitle() As String
'Gets the current title of Winamps window. (Useful for track information)
'Usage Example: Send "Current Title: " & clsWinamp.GetTitle

Dim WinampTitle As String

   If CheckWinamp = True Then
       WinampTitle = Space$(GetWindowTextLength(FindWindow("Winamp v1.x", vbNullString)) + 1)
       
       Call GetWindowText(FindWindow("Winamp v1.x", vbNullString), _
       WinampTitle, Len(WinampTitle))
           
       GetTitle = WinampTitle
   End If

End Function

Dyndrilliac

#50
Public Function FindWinamp() As Long
'Find winamp window
'Returns 1 if winamp is open, 0 if not
   Dim hMenuSystem As Long
   
   hwnd_winamp = FindWindow("Winamp v1.x", vbNullString)
   hMenuSystem = GetSystemMenu(hwnd_winamp, 0)
   hMenuWinamp = GetSubMenu(hMenuSystem, 0)
   hMenuOptions = GetSubMenu(hMenuWinamp, 11)
   
   If hwnd_winamp Then FindWinamp = 1 Else FindWinamp = 0
End Function


Public Function SetVolume(Volume As Integer) As Long
'Sets the volume (Volume must be between 0 - 255)
   SetVolume = SendMessage(hwnd_winamp, WM_WA_IPC, Volume, IPC_SETVOLUME)
End Function

Public Function Rewind() As Long
'Rewinds by 5 seconds
   Rewind = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_REW5S, 0)
End Function

Public Function FastForward() As Long
'Fast forwards by 5 seconds
   FastForward = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_FFWD5S, 0)
End Function

Public Function PreviousTrack() As Long
'Plays the previous song
   PreviousTrack = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON1, 0)
End Function

Public Function PlaySong() As Long
'Plays the current song
   PlaySong = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON2, 0)
End Function

Public Function PauseSong() As Long
'Pauses playing
   PauseSong = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON3, 0)
End Function
Public Function StopSong() As Long
'Stops playing
   StopSong = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4, 0)
End Function

Public Function NextTrack() As Long
'Plays the next song in the playlist
   NextTrack = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON5, 0)
End Function

Public Function FadeStop() As Long
'slowly fades away until it stops
   FadeStop = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4_SHIFT, 0)
End Function

Public Function VolumeUp() As Long
'Raises the volume a tiny bit
   VolumeUp = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_VOLUMEUP, 0)
End Function
Public Function VolumeDown() As Long
'Sets the volume down a tiny bit
   VolumeDown = SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_VOLUMEDOWN, 0)
End Function

Public Function PlayFile(FileToPlay As String) As Long
'Adds FileToPlay to the play list
   Dim CDS As COPYDATASTRUCT
   CDS.dwData = IPC_PLAYFILE
   CDS.lpData = FileToPlay
   CDS.cbData = Len(FileToPlay) + 1
   PlayFile = SendMessageCDS(hwnd_winamp, WM_COPYDATA, 0, CDS)
End Function

Public Function QuitWinamp() As Long
'Quit Winamp
   QuitWinamp = PostMessage(hwnd_winamp, WM_COMMAND, WINAMP_FILE_QUIT, 0)
End Function

'gets the current song playing
Public Function GetSongTitle() As String
On Error Resume Next
Dim sSong_buffer As String * 100
'get the title
Call GetWindowText(hwnd_winamp, sSong_buffer, 99)
'edit the sSong_buffer
'xx.aaaaaa - tttttttt - Winamp
'get the track number
Dim iTrackNumber As Integer
iTrackNumber = InStr(1, sSong_buffer, ".")
TrackTitle.sTrackNumber = Trim$(Left(sSong_buffer, Val(iTrackNumber - 1)))
'get the artist
Dim iArtist As Integer
iArtist = InStr(iTrackNumber, sSong_buffer, "-")
TrackTitle.sArtist = Trim(Mid(sSong_buffer, iTrackNumber + 1, (iArtist - iTrackNumber - 1)))
Dim iSong As Integer
iSong = InStr(iArtist + 1, sSong_buffer, "-")
TrackTitle.sName = Trim(Mid(sSong_buffer, iArtist + 1, (iSong - iArtist - 1)))
'get the title
GetSongTitle = TrackTitle.sTrackNumber + ". " + TrackTitle.sArtist + " - " + TrackTitle.sName
End Function


That isn't everything in my module but that should give you the general idea.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

LizArD

sorry for ignoring everyone else however this question is for hismajesty, remember this?

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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 Const WA_COMMAND As Long = &H111

Public Enum WA_COMMANDS      'You can add more if you'd like.
   WA_PREVTRACK = &H9C6C
   WA_NEXTTRACK = &H9C70
   WA_PLAYTRACK = &H9C6D
   WA_PAUSETRACK = &H9C6E
   WA_STOPTRACK = &H9C6F
End Enum


you said I can add more if i'd like to, where do i find the other WA_COMMANDS at?

hismajesty


Grok

Quote from: hismajesty[yL] on August 14, 2004, 07:37 PM
Check NSDN

Why would MSDN have WinAmp enumerations for commands?

Banana fanna fo fanna


FrOzeN

Quote from: LizArD on August 14, 2004, 04:54 PM
you said I can add more if i'd like to, where do i find the other WA_COMMANDS at?

theres alot in my post:
WA_Previous_track = 40044
 WA_Next_track = 40048
 WA_PLAY = 40045
 WA_Pause_Unpause = 40046
 WA_STOP = 40047
 WA_Fadeout_and_stop = 40147
 WA_Stop_after_current = 40157
 WA_Fast_forward_5_seconds = 40148
 WA_Fast_rewind_5_seconds = 40144
 WA_Start_of_playlist = 40154
 WA_Go_to_end_of_playlist = 40158
 WA_Open_file_dialog = 40029
 WA_Open_URL_dialog = 40155
 WA_Open_file_info_box = 40188
 WA_Set_time_display_mode_to_elapsed = 40037
 WA_Set_time_display_mode_to_remaining = 40038
 WA_Toggle_preferences_screen = 40012
 WA_Open_visualization_options = 40190
 WA_Open_visualization_plug_in_options = 40191
 WA_Execute_current_visualization_plug_in = 40192
 WA_Toggle_about_box = 40041
 WA_Toggle_title_Autoscrolling = 40189
 WA_Toggle_always_on_top = 40019
 WA_Toggle_Windowshade = 40064
 WA_Toggle_Playlist_Windowshade = 40266
 WA_Toggle_doublesize_mode = 40165
 WA_Toggle_EQ = 40036
 WA_Toggle_playlist_editor = 40040
 WA_Toggle_main_window_visible = 40258
 WA_Toggle_minibrowser = 40298
 WA_Toggle_easymove = 40186
 WA_Raise_volume_by_1 = 40058
 WA_Lower_volume_by_1 = 40059
 WA_Toggle_repeat = 40022
 WA_Toggle_shuffle = 40023
 WA_Open_jump_to_time_dialog = 40193
 WA_Open_jump_to_file_dialog = 40194
 WA_Open_skin_selector = 40219
 WA_Configure_current_visualization_plug_in = 40221
 WA_Reload_the_current_skin = 40291
 WA_Close_Winamp = 40001
 WA_Moves_back_10_tracks_in_playlist = 40197
 WA_Show_the_edit_bookmarks = 40320
 WA_Adds_current_track_as_a_bookmark = 40321
 WA_Play_audio_CD = 40323
 WA_Load_a_preset_from_EQ = 40253
 WA_Save_a_preset_to_EQF = 40254
 WA_Opens_load_presets_dialog = 40172
 WA_Opens_auto_load_resets_dialog = 40173
 WA_Load_default_preset = 40174
 WA_Opens_save_preset_dialog = 40175
 WA_Opens_auto_load_save_preset = 40176
 WA_Opens_delete_preset_dialog = 40178
 WA_Opens_delete_an_auto_load_preset_dialog = 40180
~ FrOzeN

Grok


LizArD

However yours is a tad diff different looking then mine.... what would I use for the get track title command? for my code...



Quote from: LizArD on August 14, 2004, 04:54 PM
sorry for ignoring everyone else however this question is for hismajesty, remember this?

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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 Const WA_COMMAND As Long = &H111

Public Enum WA_COMMANDS      'You can add more if you'd like.
   WA_PREVTRACK = &H9C6C
   WA_NEXTTRACK = &H9C70
   WA_PLAYTRACK = &H9C6D
   WA_PAUSETRACK = &H9C6E
   WA_STOPTRACK = &H9C6F
End Enum


you said I can add more if i'd like to, where do i find the other WA_COMMANDS at?






WA_TRACKINFO = &??????

?

LizArD

Quote from: FrOzeN on August 13, 2004, 01:05 AM
heres probably the best way to set out the code..
this doesn't have set volume and stuff but you can add it in using info from the other 3 pages in this topic  :P

put this is a module
Public l_winamp As New Winamp 'Change if not Winamp.cls

put this a a class module (Winamp.cls)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) 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 Const m_Const_Winamp As String = "Winamp v1.x"
Private Const m_WM_COMMAND = &H111
Public Enum Enum_WA_Command
 WA_Previous_track = 40044
 WA_Next_track = 40048
 WA_PLAY = 40045
 WA_Pause_Unpause = 40046
 WA_STOP = 40047
 WA_Fadeout_and_stop = 40147
 WA_Stop_after_current = 40157
 WA_Fast_forward_5_seconds = 40148
 WA_Fast_rewind_5_seconds = 40144
 WA_Start_of_playlist = 40154
 WA_Go_to_end_of_playlist = 40158
 WA_Open_file_dialog = 40029
 WA_Open_URL_dialog = 40155
 WA_Open_file_info_box = 40188
 WA_Set_time_display_mode_to_elapsed = 40037
 WA_Set_time_display_mode_to_remaining = 40038
 WA_Toggle_preferences_screen = 40012
 WA_Open_visualization_options = 40190
 WA_Open_visualization_plug_in_options = 40191
 WA_Execute_current_visualization_plug_in = 40192
 WA_Toggle_about_box = 40041
 WA_Toggle_title_Autoscrolling = 40189
 WA_Toggle_always_on_top = 40019
 WA_Toggle_Windowshade = 40064
 WA_Toggle_Playlist_Windowshade = 40266
 WA_Toggle_doublesize_mode = 40165
 WA_Toggle_EQ = 40036
 WA_Toggle_playlist_editor = 40040
 WA_Toggle_main_window_visible = 40258
 WA_Toggle_minibrowser = 40298
 WA_Toggle_easymove = 40186
 WA_Raise_volume_by_1 = 40058
 WA_Lower_volume_by_1 = 40059
 WA_Toggle_repeat = 40022
 WA_Toggle_shuffle = 40023
 WA_Open_jump_to_time_dialog = 40193
 WA_Open_jump_to_file_dialog = 40194
 WA_Open_skin_selector = 40219
 WA_Configure_current_visualization_plug_in = 40221
 WA_Reload_the_current_skin = 40291
 WA_Close_Winamp = 40001
 WA_Moves_back_10_tracks_in_playlist = 40197
 WA_Show_the_edit_bookmarks = 40320
 WA_Adds_current_track_as_a_bookmark = 40321
 WA_Play_audio_CD = 40323
 WA_Load_a_preset_from_EQ = 40253
 WA_Save_a_preset_to_EQF = 40254
 WA_Opens_load_presets_dialog = 40172
 WA_Opens_auto_load_resets_dialog = 40173
 WA_Load_default_preset = 40174
 WA_Opens_save_preset_dialog = 40175
 WA_Opens_auto_load_save_preset = 40176
 WA_Opens_delete_preset_dialog = 40178
 WA_Opens_delete_an_auto_load_preset_dialog = 40180
End Enum
Public Function IsWinampRunning() As Boolean
 IsWinampRunning = IIf(FindWindow(m_Const_Winamp, vbNullString) = 0, False, True)
End Function

Public Sub Execute(ByVal l_Command As Enum_WA_Command)
 SendMessage FindWindow(m_Const_Winamp, vbNullString), m_WM_COMMAND, l_Command, 0
End Sub

Public Function GetWindowTitle(ByVal WindowTitle As String) As String
   Dim Title As String
   TheHWnd = FindWindow(WindowTitle, vbNullString)
       Title = Space$(GetWindowTextLength(TheHWnd) + 1)
       Call GetWindowText(TheHWnd, Title, Len(Title))
       Title = Left$(Title, Len(Title) - 1)
   GetWindowTitle = Title
End Function


usage.. this would make it play..
If l_winamp.IsWinampRunning Then l_winamp.Execute Enum_WA_Command.WA_PLAY


If I used this, how would I use it, aka commands

Guessing

Case "stop"
       Call clsWinamp.SendCommand(WA_STOP, &H111)
       Send "Winamp: Play stopped."



sorry if im totally wrong, im noobsauce =[

Soul Taker

It looks like you would use the Execute function.

|