Brass Plugins: Mime
Supported Directives: Api - Post
Message
Most application manipulation can be done by posting
messages to an application's window. This directive emulates the
win32api function PostMessage().
The format of the directive is:
[PostMessage(target
window,message id,WPARAM,LPARAM)]
Parameter 1, the target window, is the window to send the menu
command to based on its relationship to the window the gesture was
made in. This parameter may be "window", "parent",
or "overall". If you are unsure what to put in this field
you should use "overall" as most applications will not
reflect menu commands to the parent window. If
you need to send a message to a window in another application, you
must first change the target window using the SetTargetWnd() directive.
Parameter 2, the message id, is the the message you wish to send
to the window. This can either be a valid Windows message #define
(for example, WM_SETFOCUS) or a hex value representing a message
(for example, 0x0007).
Parameter 3, the WPARAM, is the hex value you wish to send as the
WPARAM parameter in the message.
Parameter 4, the LPARAM, is the hex value you wish to send as the
LPARAM parameter in the message.
Example
No specific example is possible. PostMessage() can send any message
to any window, therefore should be used when necessary. An example
could be as follows.
- Load target application
- Load Winspector.
- In Winspector, open the "Edit" menu and select "Options".
- Tick the option titled "Show message parameters on one
line".
- Drag the red bullseye window finder from Winspector on to the
target application's titlebar.
- Go back to Winspector. The target will be highlighted in the
window list.
- Right click in the "Messages" window in Winspector
(the window will say "Messages 00xxxxxx: (Notepad)"
- Make sure "Show return values" is unticked
- Return to the target application. Perform whatever action you
want to create a directive for.
- Immediately return to Winspector. Review the entries in the
message window.
- Duplicate the message ID, WPARAM and LPARAM from Winspector
into the directive.
If the following directive was run from a gesture in Notepad, the
"Font" dialog would open.
[PostMessage(overall,WM_COMMAND,0x00000025,0x0)]
WM_COMMAND is the Windows message ID to access
a menu option. 0x00000025 is the control ID of the "Font"
menu option. Review the example for the [Menu()] directive for how
this value was obtained.
Technical Notes
This directive accepts a message ID as either its
"English name" definition (WM_COMMAND, as displayed by
Winspector in the above example) or as it's equivalent DWORD value.
When specifying the message ID in DWORD form, prefix it with "0x"
to indicate a hex value. Therefore the following 2 statements are
identical in operation:
[PostMessage(overall,WM_SETFOCUS,0x0,0x0)]
[PostMessage(overall,0x0007,0x0,0x0)]
0x0007 is the hex value of the WM_SETFOCUS message
define. All the available WM_ messages can be found in Winuser.h,
or by reviewing the output of a window spy tool.
This directive supports all of the likely message
defines that could be extracted from Winuser.h. If one is missing
that you need, please let
us know.
|