Sending Keys using custom WSRMacros
We've received some comments and questions recently from users trying out the new WSR Macros utility we released on https://www.microsoft.com/downloads about keystroke macros.
Here's the scoop...
We utilize a very similar syntax for sending keys from macros as compared with other built-in functionality in the OS. However, we've extended it in a few ways. Instead of talking about the differences, I'll try to give you an overview of how we represent keystrokes.
First, what does a macro that sends keys even look like. It looks like this:
<speechMacros>
<command>
<listenFor>All Select</listenFor>
<sendKeys>{{CTRL}}a</sendKeys>
</command>
</speechMacros>
You can either generate that using our built-in wizard, or you can just type it in yourself, and save it to your Speech Macros directory.
You can see that I have {{CTRL}} preceding the letter a. That basically means, press and hold the CTRL key then press the a key, then release both. That {{CTRL}} is a modifier for the next non-modifier key. We also have {{SHIFT}} and {{ALT}} to support all the normal types of hotkeys you'd run into.
We also have a shortcut syntax for SHIFT, CTRL and ALT. You can use + for SHIFT, ^ for CTRL, and % for ALT. We didn't make this part up. This is the built-in behavior for other applications that send keys to applications. Now, if you wanted to use a plus sign, you could also escape that by using {+}. Similarly, you can use {^} and {%} to escape those characters.
In addition, you could have need for actually pressing the CTRL key and then releasing it, not actually using it as a modifier. To do that, just use {CTRL} instead of {{CTRL}}. The simple rule here is that modifiers have two brace characters surrounding them, but can be used as actual keys by only using a single brace character.
There are also many special keys you'd like to send that we've also represented. Here's the full list:
{BACKSPACE}
{BS}
{BKSP}
{CAPSLOCK}
{DEL}
{DELETE}
{DOWN}
{END}
{ENTER}
{ESC}
{HOME}
{INS}
{INSERT}
{LEFT}
{NUMLOCK}
{PGDN}
{PGUP}
{RIGHT}
{SCROLLLOCK}
{TAB}
{UP}
{F1}
{F2}
{F3}
{F4}
{F5}
{F6}
{F7}
{F8}
{F9}
{F10}
{F11}
{F12}
{NUM0}
{NUM1}
{NUM2}
{NUM3}
{NUM4}
{NUM5}
{NUM6}
{NUM7}
{NUM8}
{NUM9}
{NUM+}
{NUM-}
{NUM*}
{NUM/}
{NUM.}
{NUM~}
{LALT}
{ALT}
{RALT}
{LSHIFT}
{SHIFT}
{RSHIFT}
{LCTRL}
{CTRL}
{RCTRL}
{LWIN}
{WIN}
{RWIN}
{MENU}
{BREAK}
{PRTSC}
{SLEEP}
{CAPSLOCK+}
{CAPSLOCK-}
{NUMLOCK+}
{NUMLOCK-}
{SCROLLLOCK+}
{SCROLLLOCK-}
Each of these can also be used as a modifier as well, just enclose them in another set of braces.
There are some other abilities too, such as sending unicode characters, inserting delays, and more... I'll save those for another post another day.
Remember, if you have questions, send them to us at listen@microsoft.com.