Controlling non-MIDI software (like Photoshop) via MIDI

florian

2016-07-15 23:59:48

A user wrote:
I would like to configure my controller's pitch bend to control a parameter like ex brush opacity in Photoshop.
The same with a slider or a rotating knob to control incremental or sliding values (color, hue etc)
It is definitely possible to do that with MIDI Translator Pro (MT Pro).

If your target application (e.g. Photoshop) does not understand MIDI, you can use MIDI Translator Pro to convert incoming MIDI messages to other input events which are received by the target application.

Note, however, that MT Pro is somewhat generic, so you won't find commands to directly access Photoshop functions. Instead, you need to build it yourself.

So let's break it down:

1) Options for controlling a non-MIDI application
There are different ways to address, e.g., the opacity via MIDI Translator Pro.

Keystrokes: emulate arbitrary keystrokes in response to the incoming MIDI messages from your controller. Like that you can invoke a keyboard shortcut to change the opacity, or select a particular setting in Photoshop. For keystrokes to work, it's typically necessary to have the target application (Photoshop) in focus, i.e. the front most application.

Mouse: emulate mouse pointing and clicking. You can use MT Pro to do arbitrary actions with the mouse in response to MIDI messages. Like that, you can click on the Opacity value, and move the visual opacity slider. The usual problem with mouse emulation is that the position on screen is fixed, so if you move Photoshop's window, or the opacity setting gets shifted to another position (e.g. from top to bottom bar), the mouse will not hit the correct control.

Injection (Windows only): If you're on Windows, you can inject both keystrokes and mouse emulation. Injecting means that the target application does not need to be in foreground, and you can precisely choose the control which you want to control. Like that, mouse positions are relative to the target control (e.g. opacity value field), and you'll always hit it with the mouse, no matter where on the screen it is. The problem with injection is that it does not work with all target programs, so you just need to try and see if it works. I've tried it with Photoshop (see attachment) and it works great for mouse emulation, but not always with keystrokes.

AppleScript (OS X only): if you're on OS X, you can use AppleScript scripts to control other applications. The possibilities are endless, but requires to learn a bit about AS.

2) Using a MIDI message to virtually press a visual button
This is usually relatively easy to implement in MIDI Translator Pro using one of the methods outlined above.

3) Using a MIDI Controller or Pitch Bend to change a visual control
The problem here is that the MIDI message contains an absolute position, which you need to somehow translate to keystroke and mouse events. It's not rocket science, but requires some thinking.

4) Putting it altogether
I've done some tests with Photoshop, and on Windows the best solution I could come up with is to
  • focus the Opacity number field with injection (translator 0, using a Note On message)
  • use global (non-injected) keystrokes to press the "up" key for increasing the value, and to press the "down" key for decreasing the value. It didn't work well with injection, so Photoshop must be the active program.
  • use simple rules for detecting if the last pitch bend movement was upwards or downwards
It would be a bit out of scope to explain how the rules work, but maybe they make sense anyway. In a nutshell, they convert absolute positioning (as in: wheel position X) to a series of Up or Down keystrokes (relative). There are a couple of discussions for converting absolute to relative (and vice versa).

It's probably a good idea to play with the attached project file, possibly replacing the incoming messages with ones better suited for your application, etc.

Hope that helps for a start!
Florian
Attachments
Photoshop.bmtp
(1.63 KiB) Downloaded 516 times