Welcome to the MP3Car.com forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
|
09-10-2006, 12:38 PM
|
#1
|
|
Maximum Bitrate
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
|
Setting winamp volume via API in VB6
I'm trying to set the volume in winamp via an API call. I can see, via debug mode, that FindWindow gives hwndWinamp a six digit number (seems good?) and that SendMessage returns 0. The thing is, nothing happens?
Code:
'Declare SendMessage
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Long) As Long
'Declare FindWindow
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hwndWinamp As Long
Dim tmp As Long
hwndWinamp = FindWindow("Winamp v1.x", vbNullString)
If hwndWinamp = 0 Then MsgBox "Couldn't find Winamp"
tmp = SendMessage(hwndWinamp, WM_USER, 122, 122)
End Sub
|
|
|
09-10-2006, 03:11 PM
|
#2
|
|
Maximum Bitrate
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
|
I'm not great with VB6 but I'm gonna try to help you anyway.
First of all, everthing if referenced to this page.
Looking through your code I couldn't find any value of WM_USER.
It's a constant and must be equal to 0x400 (In VB: &H400).
OK, now, to set the volume to a desired value between 0 and 255:
Code:
SendMessage(hwndWinamp, WM_USER, <volume>, 122)
To increase volume by an increment of 1%:
Code:
SendMessage(hwndWinamp, WM_COMMAND, 40058, 0)
To decrease volume by an increment of 1%:
Code:
SendMessage(hwndWinamp, WM_COMMAND, 40059, 0)
*NOTE: WM_COMMAND = 0x0111 (In VB: &H111)
Enjoy! 
__________________
For Sale: Carputer (CarPC) & RCA Y-Adapter
Newsflash: Take a look at my unsold stuff above, thanks!
Up Next: Make an OBD to Serial cable & Redo the "MMI buttons"
|
|
|
09-10-2006, 03:24 PM
|
#3
|
|
Maximum Bitrate
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
|
I changed the code to this:
Code:
'Declare SendMessage
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
'Declare FindWindow
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hwndWinamp As Long
Dim tmp As Long
Dim WM_USER As Long
WM_USER = &H400
Dim WM_COMMAND As Long
WM_COMMAND = &H111
hwndWinamp = FindWindow("Winamp v1.x", vbNullString)
If hwndWinamp = 0 Then MsgBox "Couldn't find Winamp"
tmp = SendMessage(hwndWinamp, WM_USER, 150, 122)
End Sub
But it still doesnt work. Thou
Code:
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0)
works. (next file) Strange =/
Last edited by Maņana : 09-10-2006 at 03:27 PM.
|
|
|
09-10-2006, 03:53 PM
|
#4
|
|
Maximum Bitrate
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
|
There must be a problem with your VB code (I don't know enough to help you there).
Here's how the program is written in AutoIt:
Code:
Const $WM_USER = 0x400
Opt ("WinTitleMatchMode", 4) ;Sets the mode to 'classname=*' titlematch
$WAhandle = ControlGetHandle("classname=Winamp v1.x", "", 0) ;Gets the Winamp Handle
If @error = 1 Then
MsgBox(16, "Fatal Error:", "Winamp not found.")
Exit
EndIf
$input = InputBox("Enter Volume:", "Please enter the volume you wish to set" &@CRLF&"(0 - 100%):")
If $input >= 0 AND $input <= 100 Then
DllCall("user32.dll", "int", "SendMessage", "hwnd", $WAhandle, "int", $WM_USER, "int", ($input*255/100), "int", 122) ;Set the Volume to $input * 255 / 100
Else
MsgBox(16, "Fatal Error:", "Value entered is not valid.")
Exit
EndIf
And here's the compiled exe file.
__________________
For Sale: Carputer (CarPC) & RCA Y-Adapter
Newsflash: Take a look at my unsold stuff above, thanks!
Up Next: Make an OBD to Serial cable & Redo the "MMI buttons"
|
|
|
09-10-2006, 03:55 PM
|
#5
|
|
FreeDrive Creator
Join Date: Feb 2004
Location: Manchester
Vehicle: Ferrari 360 (nearly)
Posts: 3,197
|
go grab the RR source code, in there you will find a module which will allow you to do everything you want within winamp.
CdR
|
|
|
09-10-2006, 04:00 PM
|
#6
|
|
Maximum Bitrate
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
|
Quote: Originally Posted by CdRsKuLL 
go grab the RR source code, in there you will find a module which will allow you to do everything you want within winamp.
CdR
Yes!
It's called 'WinAMP_Control' -- I'm still using it as a reference every once in a while.
__________________
For Sale: Carputer (CarPC) & RCA Y-Adapter
Newsflash: Take a look at my unsold stuff above, thanks!
Up Next: Make an OBD to Serial cable & Redo the "MMI buttons"
|
|
|
09-11-2006, 08:47 AM
|
#7
|
|
Maximum Bitrate
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
|
Well, since the AutoIT code worked, I'll just stick with it. Thanks! =)
|
|
|
10-15-2006, 05:56 PM
|
#8
|
|
Newbie
Join Date: Sep 2006
Posts: 15
|
Winamp control source code for VB6
There is another example at http://www.industrialmightandlogic.com. Its really designed to work with Input / Output cards like the velleman k8055 or k8061 but the core of the code is simple enough (all the winamp operations are wrapped into a single class). You may want to take a look at it.
|
|
|
04-25-2008, 07:32 AM
|
#9
|
|
Newbie
Join Date: Apr 2008
Posts: 1
|
solution
add the word"ByVal" in the SendMessage declaration:
...ByVal lParam As Long
then it should work.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:52 AM.
|
|