WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to use a WM_USER command in a SendMessage

 Keywords:  How to use a WM_USER command in a SendMessage.txt intControl 22 23 clear Winamp internal playlist

Question:

I tried using IntControl 22 to send a message to WinAmp. I am probably doing something wrong, but I do not know what ? I have attached a very simple WinBatch script,

Step 1 works very well :) Step 2 does not work at all :( ??

Could you please have a look at my script and let me know what I am doing wrong ? I am running this script on the same machine where WinAmp is installed.

I have attached WinAmp 2.81 (this is the latest V2 release of WinAmp) Also, this is the WinAmp like that explains how to do a SendMessage() http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml

;********************* 
;    SAMPLE CODE 
;********************* 
;If you installed WinAmp2.81 on a local and execute this script 
;Step 1 WORKS very well, but I cannot get Step 2 to work at all 

hwnd = DLLHwnd("~Winamp") 
WM_COMMAND =  273 
WM_USER    = 1024 

NextTrack  = 40048 
ClearPlayList  = 101 

;Step 1 
;This example WORKS PERFECTLY and it forces Winamp to change track 
IntControl(23, hwnd, WM_COMMAND, NextTrack, 0) 

;Step 2 
;This example is supposed to clear Winamp's internal playlist - DOES NOT WORK !!! 
IntControl(22, hwnd, WM_USER, ClearPlayList, 0) 

Answer:

First of all, you will need to make sure you are grabbing the appropriate window handle.

The documentation at the WinAmp website states:

‘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"’

Therefore I changed the code to use the Control Manager Extender function cFindbyClass. This function can locate the window that has the class type "Winamp v1.x".

The code you sent had the last two parameters swapped. The website you pointed me to indicated the following.

Notice:

‘WM_USER messages are sent using SendMessage(). In C/C++, you can send these messages by calling:

int ret=SendMessage(hwndWinamp,WM_USER, data, id);
“data” is used by many of the messages, but not all. For messages where the meaning of data is not defined, simply use 0.‘

The WM_USER message should be passed as the last parameter.

And finally, I chose to use IntControl 23 (PostMessage), instead of Intcontrol 22 (SendMessage), because the last parameter of the Intcontrol 22 function, expects a string not an integer. You need to pass the integer value 101 to clear the play list.

Here is the revised code that should work:

 

;********************* 

;    SAMPLE CODE 

;********************* 

AddExtender("wwctl34i.dll")

sAppClass = "Winamp v1.x"

hWnd  = cFindbyClass(sAppClass)

WM_USER             = 1024
DATA                 = 0
CLR_PLAY_LST        = 101

;clear Winamp's internal playlist

IntControl(23, hwnd, WM_USER, DATA, CLR_PLAY_LST)

Article ID:   W15542
File Created: 2003:05:13:11:28:38
Last Updated: 2003:05:13:11:28:38