PDA

View Full Version : How do I tell MEL that I have a key on the keyboard hold down



maurizio1974
02-27-2006, 04:30 PM
Hi

my question is on how to make MEL check for a button pressed on the keyboard like the "shift" button, so that in that case I can execute different code.Basically what I need to do is to execute a mel script that selects all the control on a specific herarchy based on the selection of a proxy object attached to the rig ( that part I already figured out ) what I need to have is if something is selected and the script is run again to select the other hierarchy I am trying to select, like first the control rig of the right arm than the left if the shift button is pressed on the keyboard.
hope I am clear enough on the explanation.

thank you in advance

sunder
02-27-2006, 07:51 PM
You'll need to use code for modifier keys.
Take this code and make it a shelf button. Shift-clicking it will select all objects in your selection that start with the word "left"; anything else will select all objects starting with "right".

////
int $modifier = `getModifiers`;
print($modifier);
//Check if only SHIFT is pressed
if ($modifier==1) {
print("Shift is pressed");
select `ls -sl "left*"`;
}
else {
print("Shift NOT pressed");
select `ls -sl "right*"`;
}
//////

The modifier variable value is quite interesting and can be used to get a combo of keys. Shift is 1 and Alt is 8, so to check if shift+alt is pressed, you check if the $modifier value is (1+8) 9. Likewise, Ctrl is 4 and Alt is 8, so ctrl+alt is 12. And Ctrl+Shift+Alt is 13.
Enjoy ;)

maurizio1974
02-28-2006, 03:36 PM
Thank you very much

you are the man !!!