Well keystrokes are a bit difficult in MT Pro, however it is possible. You just have to assign a note number for every possible outgoing keystroke. In this case I assigned them loosely based on their ascii codes that would be used for serial data.
For this exersize, I called the plugin name ‘Hi’ so I only defined 4 keystroke translators
- Cmd(F) - Control F on my Windows machine
- H
- i
- Return
If you want more keystrokes, you will have to add similar translators for each keystroke desired.
The perform action takes two incoming parameters. The first is the ascii key code and the second is the amount of delay you want before you send the keystroke. The delay is in milliseconds.
So this is how it works
Translator 0.0 takes a note on note 0 value 127 for a trigger input.
The outgoing action is Perform ‘Button1’ with a value of 0 (which is the sequence number.
Translator 0.1 looks at the sequence number and decided which character to send and what delay to add.
One of the rules is to trigger a Perform ‘Keystroke’ action with the character number and the delay
Then the outgoing action triggers itself again after incrementing the sequence number
IMPORTANT - There is a rule to make sure after all characters are sent, no more Perform actions are triggered.
The application must have focus because it will send to the currently focused application. You could first add another translator to focus the application if you want, then put a delay on the other translators that are already written.
Here are the rules of incoming Perform ‘Button1’. You could do similar translators for other desired sequences.
// pp is the sequence number
// default delay in ms
ss=10
// What sequence number are we on
// rr will hold the ascii character number
// and ss the outgoing delay
if pp==0 then rr=6
// additional delay for cmd f
if pp==0 then ss=20
if pp==1 then rr=72
if pp==2 then rr=105
// additional delay for the first return
if pp==3 then ss=20
if pp==3 then rr=13
if pp==4 then rr=13
// No more characters in this sequences so quit
// BE CAREFUL NOT DO DELETE THE BELOW RULE AS YOU WILL IT
// WILL NEVER STOP
if pp>4 then exit rules, skip Outgoing Action
// Increment the sequence number
pp=pp+1
Log "Button One Pressed"
// rr is the key id and ss is the delay
Perform "Keystroke", rr,ss
// outgoing action here - pp is the sequence number
// we are calling ourself
This requires MT Pro 1.9.1 or greater to work as ‘Perform’ is a new feature that just released last month. Note, there is no need for any global variables using this technique which shows the true power of ‘Perform’ and parameter passing.
Perform-Key-Sequence.bmtp (3.4 KB)
Steve Caldwell
Bome Customer Care
Also available for paid consulting services: bome@sniz.biz