Notifications
Clear all

[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"
		)
	)
)
15 Replies

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?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

you can use shift pressed to drop content menu.

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!"
 )
 
 PEN

Could try grabbing them with dotNet?

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

it’s not easy. possible but needs User32 functions.

(@denist)
Joined: 11 months ago

Posts: 0

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…

 PEN

Really? I thought that I had done this in the past. Maybe it was only within a dotNet event.

 PEN

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]


 PEN

Gotcha. Ya I don’t think that I have ever tried that.

ALT and SHIFT are working with click on toolbar button only when UI layout is locked.
Menu Customize->Lock UI Layout (max 2009)

1 Reply
(@martinez)
Joined: 11 months ago

Posts: 0

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.

Page 1 / 2