Specify MIDI or Keystroke

Hi there. Im trying to get KM to send a Keystroke to a specific program. But I can't figure it out. Neither can I send a MIDI note to a specific midi source (choose witch midi device/output i want to send to). Are there any workarounds or am I missing something?

All the best. Eriko

What's the app?

Most apps should respond to this:

  • Create a macro in a macro group which is activated when the app is frontmost
  • In the macro:
    • Insert Action: "Type a Keystroke"

After you insert the action, press the keystroke you want, which will replace the default entry of RETURN.

Getting Started with Keyboard Maestro

  • Read the Quick Start.
    • This is essential to become familiar with KM terminology
  • Do the tutorial (Help ➤ Tutorial) in the KM Editor.
    • Gives you a live walkthrough of creating a macro in the KM Editor
  • Review/Browse the Available Macro Actions
  • For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
  • Start small, and grow your macros organically.
  • Be prepared for some trial and error in the beginning.
  • Make good use of this Keyboard Maestro Forum
    • Search for existing macros
    • Post your questions/issues if you get stuck

Sure thing. I have tried that. But I want to send keystrokes to programs running in the background. Thats why I need to specify witch program the keystroke is for. Similar to the function in Osculator. There you can send a keystroke to a program of your choice…

AFAIK, the macOS only supports sending keystrokes (which is a UI activity) to the frontmost app/window. I don't know anything about Osculator.

But in Keyboard Maestro, you will need to bring the app/window to the front, send the keystroke, and the restore the last app.

In the below example, I am using TextWrangler as the target app.

Keyboard Maestro does not support sending keystrokes to background apps, nor directing where MIDI notes go.

Thanks for clearing that out. Still that would be a very nice feature. And to top it of I would die for OSC implementation : )

Have a fantastic day…

Its on the list. As is OSC.

1 Like

Sounds great! That would make my KM workflows much better! Hope that tomorrow comes quickly :+1:t3:

Another big vote for OSC. I use OSC constantly to communicate with Reaper on Mac via Lemur on the iPad.

Thank you for your fantastic program that so many of us rely on in our workflow.

Any news on implementing OSC? For me it would be such a huge improvement on KM and what it is capable of.

/All the best from Stockholm

Not at this time.

Bummer I’m still hoping for OSC to be implemented. Well, how about the functionality to specify MIDI source or send Keystrokes to a specific program?

Just wanted to check in on this. I know it’s still quite specific, but OSC is getting more and more popular. An integration would the amazing !

Keyboard Maestro will have much more complete MIDI support.

As far as OSC, as discussed the other thread

However, I cannot see how I can use MIDI SysEx constructively. It seems it each device has its own behaviour. I could define my own and use that as a trigger, but how would that be better than the existing MIDI triggers? And how would I send such a packet constructively. There would need to be some language for describing the packet and by that point it would be better done using a third-party tool.

I also looked at OSC and came to much the same conclusion. MIDI has system support in coreMIDI and supports for MIDI over the net, but I can't even see how I would make Keyboard Maestro discoverable. And sending OSC seems to have the same sorts of issues as SysEx - what events would I actually send?

So if anyone wants any actions or triggers related to SysEx or OSC, could you please explain what that would look like (a quick mockup of a trigger or an action would be ideal) and how would it work interoperating with other devices?

OSC seem very specific to devices and packets and so I can't really see how Keyboard Maestro would sensibly trigger or send them. Also, the system does not appear to have any OSC support, and there does not seem to be any sensible discovery mechanisms.

1 Like

I believe that the topic of implementing extended MIDI capabilities has not yet been implemented?
Here is my specific task for using KM:

  1. trigger: track GUI changes when Logic pro X (LPX) is running in cases where there is no explicit generation of messages from LPX to the external environment when using MIDI controllers to control DAW (for example: - there is a "compare" button in each FX GUI window)
    1.1. when changing any FX parameters, the "compare" button changes its state, which can be tracked using applescript.

  2. Feedback/Action: The changed state data needs to be sent to the DAW MIDI controller in the form of feedback to turn on the illumination of a certain button - which has been assigned as a doubler for the GUI "compare" button.
    2.1 The MIDI controller accepts only Note On/Off, CC#, or Sysex signals for such manipulations. for the first two types of MIDI - a specific assignment of additional parameters is required except for Note on or CC number (namely, the assignment of a specific midiDevice; and midiVirtualPort name) otherwise the message will be sent to all connected peripheral devices! who will react to it differently, .. this is not desirable ...
    note: even if a single peripheral MIDI device is connected, it can have several virtual destination ports (up to 6 and higher) that are responsible for different mapping zones.
    it is for these transformations that a single application is required that, in its simplified dialog boxes, accepted aplescript and processed the signal in MIDI.

Changing of state cannot be used as a trigger unless the state generates an event.

To continuously poll and application’s state would be prohibitively expensive in CPU and battery.

I don't know what any of that means.

Keyboard Maestro sends MIDI packets, it does not have any support for routing them.

I think you are going to need some sort of other application that deals with distributing MIDI packets to specific devices, that is not something Keyboard Maestro is likely to support.

It can detect packets in any form sent to it, and it can produce packets and send them out, but it does not direct them once they are sent.

Keyboard Maestro sends MIDI packets, it does not have any support for routing them.

I tried this method, but the KM splits SysEx message into 3 parts:
for example: F0 00 00 66 10 12 90 64 7F F7

12:39:43.200	From Keyboard Maestro	SysEx		Loud Technologies / Mackie $6 bytes	F0 00 00 66 10 12
12:39:43.200	From Keyboard Maestro	Note On	1	$64	$7F
12:39:43.200	From Keyboard Maestro	Invalid		$1 bytes

The last invalid message byte is F7 - EOX

Thus the second message is intercepted by LPX and everything else is discarded as unreachable.

Maybe the "send raw packets" syntax should be somehow strictly defined for SysEx messages? Since the above behavior of KM when sending MIDI packets is very strange. Otherwise how to understand the logic of sending SysEx messages? Which must be a single sentence/phrase enclosed between F0 ... F7 according the rules of MIDI!

Keyboard Maestro sends the bytes as a single packet, so I don't know why or who is breaking the bytes into parts I'm afraid. The code used to send the entire packet is:

MIDIPacket* p_head = MIDIPacketListInit(pktlist);
MIDIPacketListAdd( pktlist, kMIDIPacketListSize, p_head, 0, len, data );
MIDIReceived( gMIDIEndpoint, pktlist );

It is a single array of bytes. So whatever happens to break them up happens after it leaves Keyboard Maestro code.

I wouldn't say so if it weren't for the facts provided by MIDI Monitor app.
try to send my message yourself:

F0 00 00 66 10 12 90 64 7F F7

and monitor the result of sending, and not the reaction to this message (since you don’t have the device that the Sysex message refers to ... it’s simple: the message must to pass unprocessed with anything) If you get the same result, then it’s not MIDI the monitor breaks it into 3 separate parts, and KM faults
KM bag

I think you'll find it's the 90 in your sysex that's causing a problem. Change it to 7F and it's OK. This shows a successful message (with 7F) followed by an incorrect one (with 80):

I'm no expert but have dabbled...

1 Like