Esta página ainda não foi traduzida, pedimos desculpa pela inconveniência
Programadores > How to find CmdIds

How to find CmdIds?

Written by vikke and CookieRevised @ 12/14/07

Index

What is a CmdId, and why do I care?

Windows software is built on what we call Windows-messages, the Windows-message for button-actions is called WM_COMMAND. Each Windows-message has a wParam and lParam (don't worry if you don't know what this means). Each button in Messenger has it's own unique CmdId. When a button is clicked inside Messenger, the WM_COMMAND message gets sent, and it's wParam contains the CmdId for the button. Messenger retrieves this message, reads the wParam to identify which button is getting clicked, and executes the corresponding command.

So to sum it 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 which CmdId the button has. We need to find out that CmdId in order to create a button which does the task the original button would do. When the user clicks our button, the identical message will be sent and Messenger does the task.

Read the WM_COMMAND documentation for more info.


Using Winspector

Winspector is a free tool to view Windows-messages sent to any window. Download it, install, and fire it up.

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 Windows-messages are displayed. However we want to filter out all messages but WM_COMMAND, searching through 1000's and 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.


Using Resource Hacker

If you want to duplicate an action which is also available in some menu in Messenger, you can also simply use a resource editor, like Resource Hacker, and check the menu resources. The CmdId will be listed in plain sight there:

  • Launch your favorite resource editor (like Resource Hacker)
  • Open the language file of Messenger (eg: msgslang.8.5.1302.1018.dll)
  • Select the Menu resource table
  • Search for the text of the menu item which action you want to duplicate
    Note: Don't forget to include the ampersand (&) in your search text.
  • Locate the CmdId

For example:
Finding Messenger CmdIds in Resource Hacker
Thus, the CmdId for setting your status to busy is 40168.

This method is much quicker and requires less knowledge. But it will only work if the action you want to duplicate is available somewhere in some menu.