|
![]() |
#1 |
Passionately Apathetic
Administrator Join Date: May 2000
Location: Hell
Posts: 5,435
|
Winamp Application Programming Interface
How to communicate with Winamp from plug-ins and other applications.
Please note that the following is supplied as a historic reference to Winamp Interfacing, much of which has been outdated by the latest SDK Original document located in NSDN is no longer available 1. Using the Command Line Interface 2. Using Windows Messages 2.1 Determining the Winamp window 2.2 Using WM_COMMAND messages 2.3 Using WM_USER messages 2.4 Using WM_COPYDATA messages 3. Other Useful techniques 1. Using the command line interface to control Winamp Note: New 5.11+ multi user/instance commandline switches can be found below. The simplest, easiest, least powerful way of controlling Winamp is to execute winamp.exe yourself. By simply calling winamp.exe with various command line options, you do a number of things. For example:
As you might notice, what you can actually do using the command line interface is pretty limited. It is really easy to get started with, though. You can also specify multiple files and or directories on the command line, such as:
For more advanced Command Line switches you can use a plugin such as WACommand. 2. Using Windows Messages to control Winamp 2.1 Determining the Winamp window Winamp is a 32-bit Windows application. Having said that, we'll assume some basic knowledge of 32 bit Windows programming. Winamp can be controlled using the Windows Message system. Before you can send Winamp messages, you have to determine its Window Handle. There are two primary ways of doing that, one for external applications, and another for plug-ins. Plug-ins simply get passed a HWND to Winamp in their respective structures. The variable is usually named hwndWinamp or hwndParent. External applications can find the Winamp window using the following pieces of code: C/C++: code: HWND hwndWinamp = FindWindow("Winamp v1.x",NULL); VBasic: code: Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Delphi Pascal: code: var hwndWinamp : THandle; Note that this code uses the FindWindow() function to find a window of any title whose class name is "Winamp v1.x". All versions of Winamp 1.x and 2.x have the class "Winamp v1.x", unless changed using the /CLASS= switch (see above). Note that if you want to run multiple Winamp's and easily tell the difference between them, you can use the /CLASS= switch. Message types Winamp understands Winamp responds to three messages in particular: WM_USER, WM_COMMAND, and WM_COPYDATA. WM_USER and WM_COPYDATA allow you to control some of the more advanced aspects of Winamp while WM_COMMAND lets you do simple things such as simulate the pause button being pressed. 2.2 WM_COMMAND Messages
2.3 WM_USER Messages WM_USER messages are sent using SendMessage(). In C/C++, you can send these messages by calling: code:
data is used by many of the messages, but not all. For messages where the meaning of data is not defined, simply use 0. Here is a list of the currently supported ids that you can use from within Winamp plug-ins or from other applications (see plug-in only WM_USER messages, below, for more):
Here is a list of the currently supported ids that you can only use from within Winamp plug-ins (since they depend on running in the same process as Winamp):
2.4 WM_COPYDATA Messages WM_COPYDATA messages are sent using SendMessage() and a COPYDATASTRUCT structure. In C/C++, you can send these messages by using: code:
To get the directory where skin bitmaps are stored (useful for plug-ins to support their own skins): code:
Other Useful Techniques There are a number of other things you can do to query/control Winamp. For example, this C/C++ code fragment will get the title of the current song playing in Winamp. A simple explanation is that it retrieves Winamp's window title, removes the trailing ' - Winamp'. code:
|
![]() |
![]() |
#2 |
Junior Member
|
When it comes to retrive the version of Winamp this returns the wrong hexvalue for versions such as 2.77 and 2.80, but the right value for version 5.03. (These are the only versons I tested...).
Above text says: "Version will be 0x20yx for 2.yx" Version 2.77 (and 2.80) returns 2707 (and 2800) which will be version 2.07 and 2.00 according to above text... Version 5.03 returns 5003, which is correct. (Please excuse my poor english) |
![]() |
![]() |
#3 |
Join Date: Sep 2003
Posts: 27,873
|
How to communicate with Winamp from plug-ins and other applications.
Please note that the following is supplied as a historic reference to Winamp Interfacing, much of which has been outdated by the latest SDK Original document located in NSDN is no longer available 1. Using the Command Line Interface 2. Using Windows Messages 2.1 Determining the Winamp window 2.2 Using WM_COMMAND messages 2.3 Using WM_USER messages 2.4 Using WM_COPYDATA messages 3. Other Useful techniques 1. Using the command line interface to control Winamp The simplest, easiest, least powerful way of controlling Winamp is to execute winamp.exe yourself. By simply calling winamp.exe with various command line options, you do a number of things. For example:
As you might notice, what you can actually do using the command line interface is pretty limited. It is really easy to get started with, though. You can also specify multiple files and or directories on the command line, such as:
2. Using Windows Messages to control Winamp 2.1 Determining the Winamp window Winamp is a 32-bit Windows application. Having said that, we'll assume some basic knowledge of 32 bit Windows programming. Winamp can be controlled using the Windows Message system. Before you can send Winamp messages, you have to determine its Window Handle. There are two primary ways of doing that, one for external applications, and another for plug-ins. Plug-ins simply get passed a HWND to Winamp in their respective structures. The variable is usually named hwndWinamp or hwndParent. External applications can find the Winamp window using the following pieces of code: C/C++: code: HWND hwndWinamp = FindWindow("Winamp v1.x",NULL); VBasic: code: Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Delphi Pascal: code: var hwndWinamp : THandle; Note that this code uses the FindWindow() function to find a window of any title whose class name is "Winamp v1.x". All versions of Winamp 1.x and 2.x have the class "Winamp v1.x", unless changed using the /CLASS= switch (see above). Note that if you want to run multiple Winamp's and easily tell the difference between them, you can use the /CLASS= switch. Message types Winamp understands Winamp responds to three messages in particular: WM_USER, WM_COMMAND, and WM_COPYDATA. WM_USER and WM_COPYDATA allow you to control some of the more advanced aspects of Winamp while WM_COMMAND lets you do simple things such as simulate the pause button being pressed. 2.2 WM_COMMAND Messages
2.3 WM_USER Messages WM_USER messages are sent using SendMessage(). In C/C++, you can send these messages by calling: code:
data is used by many of the messages, but not all. For messages where the meaning of data is not defined, simply use 0. Here is a list of the currently supported ids that you can use from within Winamp plug-ins or from other applications (see plug-in only WM_USER messages, below, for more):
Here is a list of the currently supported ids that you can only use from within Winamp plug-ins (since they depend on running in the same process as Winamp):
2.4 WM_COPYDATA Messages WM_COPYDATA messages are sent using SendMessage() and a COPYDATASTRUCT structure. In C/C++, you can send these messages by using: code:
To get the directory where skin bitmaps are stored (useful for plug-ins to support their own skins): code:
Other Useful Techniques There are a number of other things you can do to query/control Winamp. For example, this C/C++ code fragment will get the title of the current song playing in Winamp. A simple explanation is that it retrieves Winamp's window title, removes the trailing ' - Winamp'. code:
|
![]() |
![]() |
#4 |
Passionately Apathetic
Administrator Join Date: May 2000
Location: Hell
Posts: 5,435
|
|
![]() |
![]() |
#5 | |
Passionately Apathetic
Administrator Join Date: May 2000
Location: Hell
Posts: 5,435
|
For those using vb.net:
Quote:
|
|
![]() |
![]() |
#6 |
Techorator
Winamp & Shoutcast Team Join Date: Jun 2000
Posts: 36,137
|
Winamp 5.11+ multi-user/instance commandline switches
Starting with Winamp 5.11, you can add commandline switches to change the ini file, ini folder and playlist folder that Winamp uses.
If all installed plugins save settings to winamp.ini (ie. the default Nullsoft ones), use: Winamp.exe /CONFIG="instance2.ini" /M3UDIR="c:\program files\winamp\instance2" If you need separate settings for a plugin that saves settings outside of winamp.ini, you'll need to change the ini directory instead of just the ini file: Winamp.exe /INIDIR="c:\program files\winamp\instance2" /M3UDIR="c:\program files\winamp\instance2" The second option will effect ALL plugins (including the media library - meaning each instance will have its own library database). Note: the above paths/filenames are variables, and can be anything you want them to be, though the destination INIDIR must already exist. |
![]() |
![]() |
#7 |
Ben Allison
Former Winamp Developer Join Date: Jan 2005
Location: Brooklyn, NY
Posts: 1,057
|
Here's a simple solution for multiple Winamps from the commandline.
Launching Winamp For the first copy: Winamp /INIDIR="%appdata%\Winamp1" /CLASS="Winamp1" For the second copy: Winamp /INIDIR="%appdata%\Winamp2" /CLASS="Winamp2" To play a file in an already open Winamp (note: this will launch Winamp, as above, if the particular copy is not open) For the first copy: Winamp /INIDIR="%appdata%\Winamp1" /CLASS="Winamp1" some.mp3 For the second copy: Winamp /INIDIR="%appdata%\Winamp2" /CLASS="Winamp2" some.mp3 To enqueue a file in an already open Winamp (note: as above, this will launch if not already open) For the first copy: Winamp /INIDIR="%appdata%\Winamp1" /CLASS="Winamp1" /ADD some.mp3 For the second copy: Winamp /INIDIR="%appdata%\Winamp2" /CLASS="Winamp2" /ADD some.mp3 The /INIDIR switch specifies where to store configuration files. I've just chosen a typical place, you can place it wherever. The /CLASS switch uniquely identifies the instance of Winamp, so that you can play and enqueue files to one particular instance when multiple ones are open. You can use any names you want (limited to about 60 characters). note: using the /CLASS switch could potentially break some third party programs and plugins that communicate with Winamp. |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|