| | 1 | = Translating MFC Messages into Events = |
| | 2 | |
| | 3 | The messages are aggregated into events using a set of rules defined in XML. The order of the rules in the XML file defines their priority. |
| | 4 | |
| | 5 | == Single Messages and Sequences == |
| | 6 | |
| | 7 | There is a distinction between single messages and whole sequences of messages of the same type. The former may be used for, e.g., {{{WM_LBUTTONDOWN}}} and {{{WM_LBUTTONUP}}}: |
| | 8 | {{{ |
| | 9 | <msg type="&WM_LBUTTONDOWN;"/> |
| | 10 | <msg type="&WM_LBUTTONUP;"/> |
| | 11 | }}} |
| | 12 | |
| | 13 | Sequences of the same message occur, e.g., when scrolling: |
| | 14 | {{{ |
| | 15 | <msg type="&WM_LBUTTONDOWN;"/> |
| | 16 | <msg type="&WM_HSCROLL;" multiple=true/> |
| | 17 | <msg type="&WM_LBUTTONUP;"/> |
| | 18 | }}} |
| | 19 | |
| | 20 | The distinction is using the {{{multiple}}} attribute of the {{{msg}}} node, |
| | 21 | which is per default false. If it is true, it means ``at least one'', similar to |
| | 22 | ``+'' in regular expressions. |
| | 23 | |
| | 24 | == Storage of messages == |
| | 25 | |
| | 26 | Each message or message sequence can be stored for later use, e.g., comparisons |
| | 27 | with other messages or generating replays. This is done using the {{{store}}} |
| | 28 | and {{{storeSeq}}} nodes: |
| | 29 | {{{ |
| | 30 | <msg type="&WM_LBUTTONDOWN;"> |
| | 31 | <store var="clicked"/> |
| | 32 | </msg> |
| | 33 | <msg type=&WM_HSCROLL;" multiple=true> |
| | 34 | <storeSeq varSeq="scrolls/> |
| | 35 | </msg> |
| | 36 | }}} |
| | 37 | |
| | 38 | When storing a message, the {{{window.hwnd}}} is automatically resolved and its |
| | 39 | target string is stored as an attribute of the message ({{{winParamType}}}). If |
| | 40 | other parameters contain HWNDs that need to be later on to address a target, |
| | 41 | they can be resolved manually and stored as a further parameter: |
| | 42 | {{{ |
| | 43 | <msg type=&WM_HSCROLL;" multiple=true> |
| | 44 | <storeSeq varSeq="scrolls> |
| | 45 | <resolveHwnd param="scrollBarHandle" storeParam="scrollBarTarget"/> |
| | 46 | </storeSeq> |
| | 47 | </msg> |
| | 48 | }}} |
| | 49 | |
| | 50 | == Checking equalities == |
| | 51 | |
| | 52 | Only matching messages by their type is insufficient. Comparisons between their |
| | 53 | parameters are also required. This can be done using {{{equals}}} nodes: |
| | 54 | {{{ |
| | 55 | <msg type="&WM_LBUTTONDOWN;"> |
| | 56 | <store var="clicked"/> |
| | 57 | </msg> |
| | 58 | <msg type="&WM_LBUTTONUP;"> |
| | 59 | <equals> |
| | 60 | <paramValue obj="this" param="window.hwnd"/> |
| | 61 | <paramvalue obj="clicked" param="window.hwnd/> |
| | 62 | </equals> |
| | 63 | </msg> |
| | 64 | }}} |
| | 65 | In the example above, the {{{equals}}} node compares whether the value of the |
| | 66 | parameter ``window.hwnd'' is equal for the stored variable ``clicked'' and the |
| | 67 | current message itself, i.e., ``this''. |
| | 68 | |
| | 69 | In general, each {{{equals}}} node has the same structure: |
| | 70 | {{{ |
| | 71 | <equals> |
| | 72 | termNode1 |
| | 73 | termNode2 |
| | 74 | </equals> |
| | 75 | }}} |
| | 76 | There are four types of term nodes: |
| | 77 | 1. {{{paramValue}}}: of the messages (example above) |
| | 78 | 1. {{{constValue}}}: constant value, e.g., {{{<constValue value="Button"/>}}} |
| | 79 | 1. {{{winInfoValue}}}: information about the target of the message. |
| | 80 | - {{{<winInfoValue obj="this" winParam="class"/>}}} for the class of the target |
| | 81 | - {{{<winInfoValue obj="this" winParam="hwnd"/>}}} for the HWND |
| | 82 | - {{{<winInfoValue obj="this" winParam="resourceId"/>}}} for the resource Id. |
| | 83 | - {{{<winInfoValue obj="this" winParam="parentTarget"/>}}} for the target of the GUI objects parent |
| | 84 | 1. {{{msgInfoValue}}}: information about the type and target of the message. |
| | 85 | - {{{<msgInfoValue obj="this" msgParam="type"/>}}} for the type of the message (its integer) |
| | 86 | - {{{<msgInfoValue obj="this" msgParam="target"/>}}} for the target of the message (its string representation) |
| | 87 | |
| | 88 | The comparison of sequence variables is not yet implemented! |
| | 89 | |
| | 90 | == Generation of replay sequences == |
| | 91 | If a message sequence has been successfully matched to a rule, a replay sequence |
| | 92 | is generated. This is done using {{{genMsg}}} and {{{genMsgSeq}}} nodes. |
| | 93 | |
| | 94 | The first way to generate a replay message is to directly replay a message that |
| | 95 | has been stored during the matching phase: |
| | 96 | {{{ |
| | 97 | <genMsg delay="100"> |
| | 98 | <storedVar obj=clicked"/> |
| | 99 | </genMsg> |
| | 100 | }}} |
| | 101 | The delay attribute signifies that the replaying tool pauses for 100 ms after |
| | 102 | sending the message stored in the variable ``clicked''. |
| | 103 | |
| | 104 | The second way is to ``construct'' it: |
| | 105 | {{{ |
| | 106 | <genMsg delay="100"> |
| | 107 | <type> |
| | 108 | <msgInfoValue obj="cmd" msgParam="type"/> |
| | 109 | </type> |
| | 110 | <target> |
| | 111 | <msgInfoValue obj="cmd" msgParam="target"/> |
| | 112 | </target> |
| | 113 | <LPARAM> |
| | 114 | <paramValue obj="cmd" param="sourceDesc"/> |
| | 115 | </LPARAM> |
| | 116 | <WPARAM> |
| | 117 | <paramValue obj="cmd" param="WPARAM"/> |
| | 118 | </WPARAM> |
| | 119 | </genMsg> |
| | 120 | }}} |
| | 121 | The type needs to be an integer. The target needs to be a target string. |
| | 122 | The LPARAM and WPARAM are both optional, their default values are 0. They can be |
| | 123 | either numerical or target strings. Furthermore, it is possible to define the |
| | 124 | HI and LO word of them separatly: |
| | 125 | {{{ |
| | 126 | <LPARAM> |
| | 127 | <LOWORD> |
| | 128 | value |
| | 129 | </LOWORD> |
| | 130 | <HIWORD> |
| | 131 | value |
| | 132 | </HIWORD> |
| | 133 | </LPARAM> |
| | 134 | }}} |
| | 135 | |
| | 136 | The value types are the same that can be used as terms for {{{equals}}} nodes. |
| | 137 | |
| | 138 | To generate message sequences, the {{{genMsgSeq}}} node is used: |
| | 139 | {{{ |
| | 140 | <genMsgSeq delay="20"> |
| | 141 | <type> |
| | 142 | <constValue value="&TBM_SETPOS;"/> |
| | 143 | </type> |
| | 144 | <target> |
| | 145 | <seqValue seqObj="scrolls" param="scrollBarTarget"/> |
| | 146 | </target> |
| | 147 | <LPARAM> |
| | 148 | <constValue value="1"/> |
| | 149 | </LPARAM> |
| | 150 | <WPARAM> |
| | 151 | <seqValue seqObj="scrolls" param="scrollPos"/> |
| | 152 | </WPARAM> |
| | 153 | </genMsgSeq> |
| | 154 | }}} |
| | 155 | The three value types used for equals are allowed. However, either the |
| | 156 | type or the target must be of a {{{seqValue}}}, otherwise the |
| | 157 | creation will fail. In case more than one {{{seqValue}}} variable is used, |
| | 158 | e.g., a different one for the LPARAM than for the target, both sequences must |
| | 159 | have the same length. |
| | 160 | |