Stefans Tools

Useful open source tools that make your life easier

SendMessage

SendMessage is a little tool to send Windows messages to any window.

Ever wondered how you should test whether your application correctly responds to certain system messages like WM_ENDSESSION or WM_POWERBROADCAST? Of course you can test your application by actually triggering those messages, but especially the WM_ENDSESSION message and its purpose makes it impossible to attach a debugger to your application once Windows sends you that message.

With this tool, you can send that message and any other message you like to your application window. And you can do that while you have a debugger attached to your application!

End session

To find the window handle of your application, either drag the target icon in the upper left to your main window, or click on the "Windows" button and select the window from the list.

Find Window Dialog

There are a few window messages predefined in SendMessage. If you need to send a message that is not in the list, just enter the number of the message and any required values for WPARAM and LPARAM manually. The screenshot below shows how this would look like for the WM_SYSCOLORCHANGE message.

Main Dialog Custom Message

Once you've entered the message information, click on either the "SendMessage" or "PostMessage" button and the message is sent or posted to your window.

If you find any bugs or have suggestions for new features, please enter them in the issue tracker.

The latest version of SendMessage is available for download here.
download

Windows XP not supported

SendMessage requires Windows Vista or later. It won't work on Windows XP!

Command line usage

SendMessage can also be used from a command line:

/message:NNNN
specifies the window message to send or post as a decimal value
/wparam:NNNN
specifies the WPARAM
/lparam:NNNN
specifies the LPARAM
/post
optional: if specified, the message is sent using PostMessage. If it's not specified, the message is sent using SendMessage.
and at least one or more of these must be specified:
/windowhandle:NNNN
the window handle to send the message to as a decimal value
/windowtitle:TTTT
the message is sent to any window that matches the specified title text
/windowclass:TTTT
the message is sent to any window that has the specified window class
/processname:TTTT
the message is sent only to windows that are part of the specified process

If only /processname:TTTT is specified without any window title, class or handle, the message is sent to the top level window of the specified process(es).

Example

SendMessage.exe /message:16 /processname:cmd.exe

Sends a WM_CLOSE message to all open console windows.