Sending keystrokes to another app

sygorox@yahoo.co.nz's icon

Hi all.
I'm looking to create a patch that takes midi input and converts it to keyboard shortcuts in order to control Pro Tools. Essentially, I would like to know if it is possible for Max to emulate typing to another app, kinda like the key object in reverse.
Thanks a lot,
Simon

robotic-audio's icon

i'm pretty sure this would be impossible... but I've been surprised before.....

Peter Castine's icon

Check if the aevent object is available for the version of Max you're
working with. David Zicarelli wrote it ages ago, but IMS it was
unsupported, so no guarantees.

If you do have it, you will still have to do some fairly low-level
work at the receiving end.

Finally, this all assumes you're on Mac OS. You don't say.

The short answer: can be done, but no one said it would be easy.

-- Peter

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine | +--> Litter Power & Litter Bundle for Jitter
|....................................................
p@castine.de | iCE: Sequencing, Recording, and Interface Building
pcastine@gmx.net | for Max/MSP
pcastine@bek.no | http://www.dspaudio.com/ Extremely cool
4-15@kagi.com |....................................................
| home|chez nous|wir|i nostri http://www.castine.de/

newsletter's icon

how about using apple script? you could send apple script messages to pro
tools...
just an idea, never tried it.

good luck,
jens

jens doering:::::::::: http://www.jensdoering.com/:::::
2av - media art::::: http://www.2av.de/ :::::::::::::::::::
jerry lusion:::::::::::: http://www.jerry-lusion.com/::::::
e.stonji:::::::::::::::::: http://www.estonji.com/:::::::::::::
hp.stonji:::::::::::::::: http://hpstonji.estonji.com/::::::::
e:gum:::::::::::::::::::: http://www.egum.net/::::::::::::::::

f.e's icon
Stefan Tiedje's icon

I don't know if thats possible, maybe some java library?
But for ProTools, what do you want to control which is not controlable
via Midi? I never had problems to communicate the essential needs to
ProTools.

All start/stop/continue/record and location is possible with MMC (Midi
Machine Control)

Stefan

--

[][] [][][] [][] [][][]
[][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

-------------------------x----
--_____-----------|-----------
--(_|_ ----|-----|-----()----
-- _|_)----|-----()-----------
----------()------------x-----

14, Av. Pr. Franklin Roosevelt,
94320 Thiais, France
Phone at CCMIX +33-1-57 42 91 09

johnp's icon

I wouldn't mess around trying to do this in Max. It can be done on
the Mac via the shell object, a lot ot escaping, and osascript, but
it's finicky, clunky and slow.

I think the old AEvents object was (and is?) OS 9 only.

On the Mac, MIDIPipe (google it) can be used to script, or send
keystrokes to, any app via AppleScript. To send keystrokes for
non-scriptable apps, a MIDIPipe AppleScript Trigger tool looks like
this:

on runme(message)
if (item 1 of message = 144) then -- note channel 1
if (item 2 of message = 127) and (item 3 of message = 0)
then -- note 127 velocity 0
tell application "Logic Pro" to activate -- app must
be in foreground to receive keystrokes
tell application "System Events"
tell process "Logic Pro" -- process name as per
Activity Monitor
        keystroke "n" using {command down, option down}
keystroke "x"
-- etc
end tell
end tell
end if
end if
end runme

--
John Pitcairn

------------------------------------------------------------ --------------
Revolver Design | Opus Locus | Auckland, New Zealand
------------------------------------------------------------ --------------

Peter Castine's icon

On 22-Mar-2006, at 22:47, John Pitcairn wrote:
> I think the old AEvents object was (and is?) OS 9 only.

What if the original query *is* about OS 9? Or even OS 8? Or, for
that matter, System 7?

Simon has never even said whether he's working on XP or Mac, so all
suggestions are being made in a vacuum.

You're right that aesend and aereceive have probably never been
Carbonized, but the hardest part would probably be finding the old
source code. The next hardest part is probably adapting to changes in
the Max API. IMS, The actual AppleEvent stuff is essentially
unchanged for Carbon.

Cocoa might be a little more effort.

Cheers,
Peter

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine | +--> Litter Power & Litter Bundle for Jitter
|....................................................
p@castine.de | iCE: Sequencing, Recording, and Interface Building
pcastine@gmx.net | for Max/MSP
pcastine@bek.no | http://www.dspaudio.com/ Extremely cool
4-15@kagi.com |....................................................
| home|chez nous|wir|i nostri http://www.castine.de/

Jennek Geels's icon

you can do this without max on XP using
http://www.bome.com/midi/translator/

on MacOS X you can send system events to other apps (including
keystrokes)
using applescript. so you have two options
- have max listen to MIDI and talk to applescript
- have applescript listen to incoming MIDI events
the first one can be done with the tap.applescript object.
I do not now of an applescript extension that listens to MIDI

HtH
-jennek