how to use WM_USER messages

Get help with using AutoHotkey and its commands and hotkeys
jemdi
Posts: 4
Joined: 06 Oct 2018, 09:42

how to use WM_USER messages

06 Oct 2018, 09:58

I've found this very interesting page http://forums.winamp.com/showthread.php?threadid=180297 about Winamp windows messages.

I can easily use the WM_COMMAND messages with this code:
sendmessage,0x111,40045,,,ahk_class Winamp v1.x

But I'm not able to use the WM_USER messages, if I write
sendmessage,0x400,100,,,ahk_class Winamp v1.x
nothing happens.

Does WM_USER work differently?
Noesis
Posts: 299
Joined: 26 Apr 2014, 07:57

Re: how to use WM_USER messages

07 Oct 2018, 07:26

Hi jemdi, Generally WM_USER messages don't work any differently to WM_Command messages. The problem is the the page you linked, isn't really explaining things very well (at least that's my view).

You'll notice the WM_Command message section has the numbers AFTER the description (I guess, implying the same message number with different wParams, or data using the page's lingo) while the WM_USER section has Numbers BEFORE the description. I interpret that as it wanting WM_USER+number for the message number to send so in you're example above, Assuming you're trying to do the play function (100), the message number would likely be WM_User + 100 (without any data i.e. 0). Also that 100 listed may or may not be hex, I'd assume it's decimal, but I could be wrong, so you should probably send message number 0x464 or 1124, and probably not 0x500 (unless it turns out they are hexadecimal). Play around a bit to work out what it actually wants (I don't have the winamp so can't really test).
User avatar
jeeswg
Posts: 6818
Joined: 19 Dec 2016, 01:58
Location: UK

Re: how to use WM_USER messages

07 Oct 2018, 07:50

- I don't have Winamp installed at the moment. (I always used Winamp 2.5e and never updated, although I did have various format plugins. I use Media Player Classic.)
- Here are the only 2 times that I used WM_USER with Winamp. Cheers.

Code: Select all

SendMessage, 0x400, 0, 105,, ahk_class Winamp v1.x ;WM_USER := 0x400
vElapsed := ErrorLevel ;milliseconds
vElapsed //= 1000 ;seconds
SendMessage, 0x400, 1, 105,, ahk_class Winamp v1.x ;WM_USER := 0x400
vDuration := ErrorLevel ;seconds
- AutoHotkey orders the parameters slightly differently from the Winapi function.

Code: Select all

;Winapi function:
SendMessage(hWnd, Msg, wParam, lParam)
;AutoHotkey v1:
SendMessage, % Msg, % wParam, % lParam,, % "ahk_id " hWnd
;AutoHotkey v2:
SendMessage(Msg, wParam, lParam,, "ahk_id " hWnd)
- Links:
SendMessage function | Microsoft Docs
https://docs.microsoft.com/en-us/window ... endmessage
PostMessage / SendMessage - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/PostMessage.htm
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
just me
Posts: 6510
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: how to use WM_USER messages

08 Oct 2018, 03:28

Code: Select all

int ret=SendMessage(hwndWinamp,WM_USER, data, id);
...
Here is a list of the currently supported ids ...
Seemingly, that numbers have to be passed in the lParam parameter of SendMessage.
jemdi
Posts: 4
Joined: 06 Oct 2018, 09:42

Re: how to use WM_USER messages

08 Oct 2018, 17:11

Thanks for your answers.

I found out that I can send some of the WM_USER messages (like the ones written by jeeswg) but not all of them (like the playback message).

I made some attempts with 0x464 0x500 or used the decimal 1124 but it doesn't work.

I know nothing about C++, is it possible to translate the following code into AHK language?
int ret=SendMessage(hwndWinamp,WM_USER, data, id)
User avatar
jeeswg
Posts: 6818
Joined: 19 Dec 2016, 01:58
Location: UK

Re: how to use WM_USER messages

08 Oct 2018, 17:20

Try this:

Code: Select all

q::
data := 1
id := 105
SendMessage, 0x400, % data, % id,, ahk_class Winamp v1.x ;WM_USER := 0x400
ret := ErrorLevel
MsgBox, % ret
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
jemdi
Posts: 4
Joined: 06 Oct 2018, 09:42

Re: how to use WM_USER messages

09 Oct 2018, 17:44

Some of the messages work, some don't.

I use this code (the same as jeeswg):
sendmessage,0x400,THIS DEPEND ON MESSAGE AND MAY BE EMPTY,NUMBER OF MESSAGE,,ahk_class Winamp v1.x

Instead of the WM_USER playback message, I can use the WM_COMMAND play and pause messages.

Do you know if there are lists of windows messages for other players (like Windows Media Player or AIMP) on the net? I made a quick search but couldn't find any.
User avatar
jeeswg
Posts: 6818
Joined: 19 Dec 2016, 01:58
Location: UK

Re: how to use WM_USER messages

09 Oct 2018, 17:51

- I only use MPC:
jeeswg's Media Player Classic tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=41683
- For other programs I would look up to see if there were any threads mentioning any automation possibilities that were available. Otherwise, I might try using Acc to invoke clicking play/pause buttons etc via accDoDefaultAction. (Or ControlClick if it uses simple Windows controls.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
jemdi
Posts: 4
Joined: 06 Oct 2018, 09:42

Re: how to use WM_USER messages

10 Oct 2018, 16:48

Interesting tutorial.

Thanks for your help.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], BreezeB, Google [Bot], hotkeyguy, hymal7, marcefw, Odlanir, RickC and 233 guests