ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
Hi, I have a rollout with a few button which i want to link to any keyboard key for easy access. even shift or alt key will do. I am not sure how to link the rollout button with key.
If you want to keep it simple then use a timer and check for any key combination on tick event
(
isKeyDown = (dotNetClass "managedservices.keyboard").isKeyDown
keys = dotNetClass "system.windows.forms.keys"
show keys
while not keyboard.escPressed do(
sleep 0.05
if isKeyDown keys.Space and isKeyDown keys.ControlKey do(format"Ctrl + Spacebar is pressed\n")))
of course it freezes max, it's just an example of the idea ;)
Use a timer control in your rollout and do these key-combination checks inside its tick event.
another example:
try(DestroyDialog ::test)catch()
rollout test "Detect Key Press" width:214(
timer clock "testClock" interval:100-- 10 times a second
local isKeyDown = (dotNetClass "managedservices.keyboard").isKeyDown
local keys = dotNetClass "system.windows.forms.keys"
CheckButton ctrl "Ctrl" width:40 pos:[4,4] across:4
CheckButton shift "Shift" width:40 pos:[46,4]
CheckButton alt "Alt" width:40 pos:[88,4]
CheckButton space "Spacebar" width:80 pos:[130,4]
fn CheckKeys =
(-- for alt, ctrl, shift & esc we can use these if alt.checked != keyboard.altPressed do alt.checked = keyboard.altPressed
if ctrl.checked != keyboard.controlPressed do ctrl.checked = keyboard.controlPressed
if shift.checked != keyboard.shiftPressed do shift.checked = keyboard.shiftPressed
-- for any other keys
local space_down = isKeyDown keys.Space
if space.checked != space_down do space.checked = space_down
)
on clock tick do(
CheckKeys()format"tick...\n"))
createDialog test
Thank you.
I shall try to implement it, and let you know.
Its very basic dotnet, still i shall need a bit time to understand it properly and tweak.
Really appreciate your quick replies.
Comments
.
If you want to keep it simple then use a timer and check for any key combination on tick event
Using macros for such task is an overkill, imho.
It is freezing max. I used it
It is freezing max. I used it both in and out of Rollout body.
Am i doing it wrong?
.
of course it freezes max, it's just an example of the idea ;)
Use a timer control in your rollout and do these key-combination checks inside its tick event.
another example:
Thank You. Will try it
Thank You. Will try it tonight. :-)
It is working perfectly.
It is working perfectly. Thanks a lot.
Thank you. I shall try to
Thank you.
I shall try to implement it, and let you know.
Its very basic dotnet, still i shall need a bit time to understand it properly and tweak.
Really appreciate your quick replies.
.
Create a macorscripts to press the keys on your toolbar.
For example:
Tools and Scripts for Autodesk 3dsMax
Its a wonderful solution.
Its a wonderful solution. Thank you Miauu.
All i have to do is assign hotkeys to that macro.