The MP3car.com Store  

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.

Go Back   MP3Car.com > Mp3Car Technical > Software & Software Development > Coders Corner

Reply
 
Thread Tools Display Modes
Old 09-10-2006, 12:38 PM   #1
Maximum Bitrate
Maņana's CarPC Specs
 
Maņana's Avatar
 
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
My Photos: (0)
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

__________________
My carputer

Old one
Maņana is offline   Reply With Quote
Sponsored Links
Old 09-10-2006, 03:11 PM   #2
Maximum Bitrate
DJiK's CarPC Specs
 
DJiK's Avatar
 
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
My Photos: (0)
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"
DJiK is offline   Reply With Quote
Old 09-10-2006, 03:24 PM   #3
Maximum Bitrate
Maņana's CarPC Specs
 
Maņana's Avatar
 
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
My Photos: (0)
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 =/
__________________
My carputer

Old one

Last edited by Maņana : 09-10-2006 at 03:27 PM.
Maņana is offline   Reply With Quote
Old 09-10-2006, 03:53 PM   #4
Maximum Bitrate
DJiK's CarPC Specs
 
DJiK's Avatar
 
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
My Photos: (0)
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"
DJiK is offline   Reply With Quote
Old 09-10-2006, 03:55 PM   #5
FreeDrive Creator
CdRsKuLL's CarPC Specs
 
CdRsKuLL's Avatar
 
Join Date: Feb 2004
Location: Manchester
Vehicle: Ferrari 360 (nearly)
Posts: 3,197
My Photos: (5)
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
__________________
http://www.extremeoc.co.uk/
Building a new car soon - check it out !

www.BluePC.co.uk Bolton PC Repair - New Business venture.. I need to earn some money :-)
CdRsKuLL is offline   Reply With Quote
Old 09-10-2006, 04:00 PM   #6
Maximum Bitrate
DJiK's CarPC Specs
 
DJiK's Avatar
 
Join Date: Apr 2005
Location: Los Angeles (Winnetka), CA
Vehicle: 1995 Audi 90 Sport Quattro
Posts: 861
My Photos: (0)
Quote: Originally Posted by CdRsKuLL View Post
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"
DJiK is offline   Reply With Quote
Old 09-11-2006, 08:47 AM   #7
Maximum Bitrate
Maņana's CarPC Specs
 
Maņana's Avatar
 
Join Date: Jul 2004
Location: Sweden
Vehicle: 98' VW Passat
Posts: 761
My Photos: (0)
Well, since the AutoIT code worked, I'll just stick with it. Thanks! =)
__________________
My carputer

Old one
Maņana is offline   Reply With Quote
Old 10-15-2006, 05:56 PM   #8
Newbie
 
Join Date: Sep 2006
Posts: 15
My Photos: (0)
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.
wheesplat is offline   Reply With Quote
Old 04-25-2008, 07:32 AM   #9
Newbie
 
Join Date: Apr 2008
Posts: 1
My Photos: (0)
solution

add the word"ByVal" in the SendMessage declaration:
...ByVal lParam As Long

then it should work.
tintinBX is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Feature request: ability to change MP3 screen volume mapping ImInSanDiego MediaCar 6 11-12-2003 09:57 PM
How to remove winamp AVS border. - Sample VB6 code Fusion-One Software & Software Development 1 10-03-2003 07:55 PM
winamp volume settings help Stine161 Software & Software Development 12 07-29-2003 10:19 PM
Remember volume setting; Arist name hotwater9 ME Archive 2 03-14-2003 01:43 PM
Setting windows default volume surfer6262 Software & Software Development 0 08-16-2002 02:10 AM


All times are GMT -5. The time now is 08:34 AM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics