Keyboard commands

Another_Guy's icon

Hi all!

Im looking for a way for MAX to send keyboard commands
i.e. when a message is banged it will "press" the Ctrl key.

(Like the opposite of the Key object...)

Is this possible?

Any help would be well received!

gwsounddsg's icon

What are you trying to send the key down/up command to do?

Another_Guy's icon

Ctrl + E to auto lock patch

Luke Hall's icon

You could do this with menu commands using applescript and the [shell] external (you can find it in the toolbox pages) or alternatively you could use the autobot java class (search the forum, it's been linked to quite a bit) and probably the most simple method: you could use the locked property of the patcher object in javascript using the [js] object.

Another_Guy's icon

Thanks Luke,

I have never used Javascript! but I suppose now is as good a time to learn...

Luke Hall's icon

I'll save you the work, here's a little abstraction I use for the same thing, with a helpfile too:

// lh.editmode.js

function bang() {
outlet(0,this.patcher.locked);
}

function lock(x) {
this.patcher.locked = x;
bang();
}

function anything() {
post("lh.editmode.js: doesn't understand ""+messagename+""n");
}

autowatch = 1;

Max Patch
Copy patch and select New From Clipboard in Max.

// EOF

Another_Guy's icon

Thank you that is so helpfull!
Do you have any other basic/intros to Java script?