[Closed] Macroscript: altPressed not working
Hi,
I’m currently writing a script which invokes keyboard.shiftPressed and keyboard.altPressed.
The thing is, that shiftPressed works fine, but alt and control don’t work AT ALL.
I just reduced the script to a very simple texting script which also wont work for alt click.
Strange thing is: I sent it to various other guys, some max 2011, some 2012 and some 2013.
For ONE guy using 2012 it worked. I cannot imagine why.
Here’s the script:
macroScript altPressedTest
category:"PatrickProbst"
toolTip:"altPressedTest"
(
on execute do
(
if (keyboard.shiftPressed) then
(
print "Shift pressed"
) else if (keyboard.altPressed) then
(
print "Alt pressed"
) else
(
print "Nothing pressed"
)
)
)
alt pressed doesn’t work with macro button pressed. same as control pressed. at least the keyboard structure doesn’t catch it.
these two modifier keys reserved for other UI (toolbar) operations.
Okay. But then why did it work for one guy?
And is there any workaround or other way to invoke multiple behaviours, like in more than two for a macroscript button?
Thank you DenisT.
Sorry to ask but I don’t exactly mean what you mean by “dropping content menu”.
Should I script a floater or something which gets shown when I press shift? What exactly do you mean?
Like I said: Sorry, still in intermediate scripter-state skillwise.
macroscript MultiChoiceMacro
category:"Do it with denisT"
buttontext:"Multi Macro"
(
rcmenu choices
(
menuitem zoomit "Zoom Extents Selected"
separator sep0
menuitem hideit "Hide"
on zoomit picked do print zoomit.text
on hideit picked do print hideit.text
)
on execute do if keyboard.shiftpressed then
(
popupmenu choices
)
else print "Action!"
)
the actual problem is the macroscript doesn’t execute (doesn’t get the event) when ALT or CONTROL pressed. So the situation needs a keyboard hooker to catch the event and evaluate the macro…
Really? I thought that I had done this in the past. Maybe it was only within a dotNet event.
Does this not work for what you are doing?
try(destroyDialog test)catch()
rollout test "Test"
(
button testBt "Test"
on testBt pressed do
(
kb=dotNetClass "system.windows.input.Keyboard"
print (kb.Modifiers==kb.Modifiers.Alt)
)
)
createDialog test pos:[10,100]
ALT and SHIFT are working with click on toolbar button only when UI layout is locked.
Menu Customize->Lock UI Layout (max 2009)
PiniO is right. If Lock UI Layout is disabled you cannot Alt/Ctrl click on toolbar buttons. This is because holding down those buttons allows you to move and duplicate toolbar buttons. You need to enable Lock UI Layout.