Using Winspector
First,
download Winspector from it's website. It's a free tool to view Windows-messages sent to any window. Windows is built on these different types of messages, and the message for button-actions is called WM_COMMAND.
Each Windows-message has a wParam and lParam (if you don't know what it is, don't worry). Each button in Messenger has it's own unique CmdId.
When a button is clicked inside Messenger, the WM_COMMAND message is getting sent, and it's wParam contains the CmdId for the button. And when Messenger retrieves the message, it reads the wParam, to identify which button is getting clicked.
Documentation on WM_COMMAND here.
So to sum up, when you click a button, a Windows-message will be sent to the Messenger-window. This message tells Messenger a button has been clicked, and it also tells which CmdId the button has. We need to find out that CmdId, in order to create a button to do the task the original button would do. When the user clicks our button, the identical message will be sent and Messenger does the task.
So, fire up Winspector. To the left you will see a list of every window running on your machine, even the hidden ones. Find the Messenger contact list window (look for
MSBLWindowClass "Windows Live Messenger" or similar), right-click on the list-item, and choose "Messages...".
Hopefully, a new window will be created inside the Winspector window, that's where all messages are displayed. However we want to filter out all messages but WM_COMMAND, searching through 1000's of 1000's of messages is not recommended.
To apply a filter, right-click on the Messages-window inside the Winspector window, and click "Edit Message Filter". Click the "Filter All" button in the new "Edit Message Filter"-window, and double-click on WM_COMMAND in the left list. If you've done this correctly you will have all messages in the left list, but WM_COMMAND in the right. Click OK, and press a button in the Messenger-window.
The Message-list inside Winspector just got updated! You should see a WM_COMMAND item in the list now. Click the "+"-button to show detailed information about that message. You will now see something like this:
Control ID: 40317.
There you go, that's the CmdId.
Plus! runs inside the Messenger-process and has the ability to retrieve these WM_COMMAND messages as well, you should be able to get Plus! command IDs as well..