Old 19th March 2004, 04:01   #1
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Unodocmented APIs

These are reverse engineered, so may not be supported too well or entirely accurate.


long libhwndipc = (LONG)SendMessage(hwndWinamp, WM_WA_IPC, (WPARAM)"LibraryGetWnd", IPC_REGISTER_WINAMP_IPCMESSAGE);

long libhmenuipc = (LONG)SendMessage(hwndWinamp, WM_WA_IPC, (WPARAM)"LibraryGetHmenu", IPC_REGISTER_WINAMP_IPCMESSAGE);

long libsendtoipc = (LONG)SendMessage(hwndWinamp, WM_WA_IPC, (WPARAM)"LibrarySendToMenu", IPC_REGISTER_WINAMP_IPCMESSAGE);


Usage:


//-1 will start the library if it hasnt loaded
//Returns the hwnd of the media library which accepts all the IPC calls
HwndMl = (HWND)SendMessage(hwndWinamp,WM_WA_IPC,0/-1,(LPARAM)libhwndipc);

//-1 will start the library if it hasnt loaded
//Returns handle to main menu of media library
HMENU menumlh = (HMENU)SendMessage(hwndWinamp, WM_WA_IPC, 0/-1, libhmenuipc);

//Called to build the 'send to:' menu within the playlist
//I think you pass a menu handle but will update if I find out more.
//Looks like it would always return -1 on success?
//Winamp calls this when building the 'send to' sub menu,
//and it causes gen_ml to add all the 'playlist x: enqueue' items and more
LRESULT lr = (HMENU)SendMessage(hwndWinamp, WM_WA_IPC, (HMENU?), libhsendtoipc);


I can get the Media library menu appearing within the playlist fine, but what I would really like is to be able to have the items actually work.

The only way I can see to do it is to construct a query/queries based on the selection, send it to the media library, then select the items in the media library then send the WM_COMMAND of the menu item. Pretty ugly hack and would involve hooking all menu item ids within the playlist wndproc... Maybe Nullsoft can implement this natively instead????

Also, its probably possible to add your own items to the Send To: menu in the playlist by hooking the IPC call. Perhaps Winamp will send you a list of selected entries when your menu is chosen if your id falls within some range reserved for 'send to playlist' menu items? Will look into it further.

Last edited by shaneh; 19th March 2004 at 04:28.
shaneh is offline   Reply With Quote
Old 25th March 2004, 04:07   #2
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
SendMessage(hwndWinamp, WM_WA_IPC, &s, libhsendtoipc);

The parameter to this message is actually a weird struct. The first byte of the struct indicates the command:

0 = Build the send to menu, return a HMENU
1 = Showing the send to menu
2 = A command was clicked
3 = List of selected files
4 = Free allocated memory?

At about offset 0x20 of the struct is where a pointer to the list of null delimeted files is stored. Note however, there is no way to get this message other than from a menu item being clicked on the send to menu. As winamp calls trackmenupopup on the send to menu and will only issue the '3' command on return from this.

It would be possible to intercept and put your own stuff on the send to menu and then intercept this '3' command, but there seems no way to get it without adding stuff to the send to menu .

There is also an undocumented(?) IPC to add hot keys with the gen_hotkeys.dll. "GenHotkeysAdd", with the parameter being a struct which contains an offset to a descriptive string, and I suppose a HWND, key command, and window message? Will work it out later on.
shaneh is offline   Reply With Quote
Old 25th March 2004, 16:40   #3
Safai
Senior Member
 
Join Date: Sep 2000
Location: Canada
Posts: 249
Send a message via ICQ to Safai
is this what you're talking about?

code:
#ifndef WA_HOTKEYS
#define WA_HOTKEYS

//#define IPC_GEN_HOTKEYS_ADD xxxx //pass a genHotkeysAddStruct * struct in data
//
//To get the IPC_GEN_HOTKEYS_ADD IPC number, do this:
//
// genhotkeys_add_ipc=SendMessage(winampWindow,WM_WA_IPC,(WPARAM)&"GenHotkeysAdd",IPC_REGISTER_WINAMP_IPCMESSAGE);
//
//Then you can use:
//
// PostMessage(winampWindow,WM_WA_IPC,(WPARAM)&myGenHotkeysAddStruct,genhotkeys_add_ipc);
//

//flags for the genHotkeysAddStruct struct
#define HKF_BRING_TO_FRONT 0x1 // calls SetForegroundWindow before sending the message
#define HKF_HWND_WPARAM 0x2 // sets wParam with Winamp's window handle
#define HKF_COPY 0x4 // copies returned text to the clipboard
#define HKF_PLPOS_WPARAM 0x8 // sets wParam with current pledit position
#define HKF_ISPLAYING_WL 0x10 // sets wParam to genHotkeysAddStruct's wParam if playing, lParam if not
// uses IPC_ISPLAYING to check if playing
#define HKF_SHOWHIDE 0x20 // brings Winamp to front or minimizes Winamp if already at front
#define HKF_NOSENDMSG 0x40 // don't send any message to the winamp window

#define HKF_DISABLED 0x80000000

typedef struct {
char *name; //name that will appear in the Global Hotkeys preferences panel
DWORD flags; //one or more flags from above
UINT uMsg; //message that will be sent to winamp's main window (must always be !=NULL)
WPARAM wParam; //wParam that will be sent to winamp's main window
LPARAM lParam; //lParam that will be sent to winamp's main window
char *id; //unique string to identify this command - case insensitive
HWND wnd; //set the HWND to send message (or 0 for main winamp window)

int extended[6]; //for future extension - always set to zero!
} genHotkeysAddStruct;

#endif

Safai is offline   Reply With Quote
Old 25th March 2004, 22:45   #4
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Yeah, didnt see that in the .h's though. Where did you pull that from? or did you make it yourself?
shaneh is offline   Reply With Quote
Old 26th March 2004, 03:00   #5
Safai
Senior Member
 
Join Date: Sep 2000
Location: Canada
Posts: 249
Send a message via ICQ to Safai
part of the wa502_sdk.zip, filename wa_hotkeys.h
Safai is offline   Reply With Quote
Old 26th March 2004, 08:00   #6
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
ok, my bad. Mine must be out of date, even though it is listed as being 5.02. But it gets updated all the time without any name changes etc so its hard to keep track :P
shaneh is offline   Reply With Quote
Old 25th April 2004, 15:56   #7
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
as far as the send-to stuff goes, how possible would it be to add a submenu to the send-to menu?

DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 27th April 2004, 02:59   #8
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
@will: It would be possible, but it would be a bit of a hack. But then so are most things when it comes to winamp plugins.

Just get the "LibrarySendToMenu" and intercept the appropriate values. The structure that is passed isn't documented anywhere, but it shouldnt be too hard to figure it out.

You will need to let the ml build the send to menu first, then add on your own sub menu. When an item is clicked, winamp will generate the '2' message with the menu id somewhere in the struct, just check if its your menu id. If it is, intercept the '3' message and obtain the filenames (a pointer is passed in the struct). You will most likely need to free this memory though...

It would take a little bit of reverse engineering, but its technically possible. Whether its worth it is another thing. Im not prepared to do this myself, unless the devs release some more documentation, or some better APIs for doing stuff like that.

(Im talking about the playlist send to menu only here, within the media library it is handled differently AFAIK).
shaneh is offline   Reply With Quote
Old 27th April 2004, 07:09   #9
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
Aah, right.

What i really want to do is add a submenu to all send-to menus.

So, I guess this isn't possible yet. :/

DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 20th August 2004, 09:05   #10
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
Why does Nullsoft hold on to hidden parts of Winamp for so long?? Is it like Christmas eve where we are excited about what we are getting!? Man....
saivert is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump