Notifications
Clear all

[Closed] Is "while keyboard button pressed/held do" possible?

 PEN

Not sure and I’m working on other things at the moment. I will have to play with this another day to see why it isn’t working for you.

Will this allow you to create sticky keys in max? Like how xsi and modo’s hotkeys work?

Say I’m in select mode and I hold down ‘w’,will it temporarily switch to the move tool and when I let go switch back to the select tool?

That seems like it would be possible.

U’d probably just have a counter, after 2000 or 3000 milliseconds it would trigger the switch, then set a variable so it isnt trying to switch to it again if your still holding the key. Then on key release, it switches that variable back and resets the counter and switch back to select.

Edit: Nevermind… that key doesn’t want to work. Also I’m not sure how to properly set that up right now. My method didn’t work… although I’m tired right now and probably not thinking this through very well at the moment.

Another way to do this that doesn’t require using a timer is to use low level keyboard hooks and limit it to Max only. I did something similar and it worked but I didn’t go further. It’s basically doing something like this:

http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

Make a .NET assembly and load it in max, call the method that starts up the keyboard hook, and make sure it’s only sending keys, if the foreground app is Max. You can even do fancy stuff like if the user is typing inside a field or Mxs listener, then you could filter them, or make them behave differently. It’s mostly oldschool win32 methods so you will have to use PInvoke, but no big deal, just a handful of methods.

Just fire an event when a successful key press is made from your .NET assembly, and add a mxs function to that event to do what you want.

Light

Very cool Light. I will have to look into this

Thanks

i will be happy to see a mxs sample. the task doesn’t look trivial for me.

1 Reply
(@light)
Joined: 11 months ago

Posts: 0

Will try to find some code in my dev archive (:

Light


 IntPtr hInstance =[b] LoadLibrary("User32");[/b]
 hhook = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 0);
 

does it make any sense?

1 Reply
(@light)
Joined: 11 months ago

Posts: 0

Yep that’s sort of the stuff I was doing. I looked some of my directories briefly but couldn’t find it. But don’t worry I am keeping this page open and will let you know if I find something.

Cheers,
Light

So what does that code do exactly?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

technically it’s a right idea but with wrong implementation. it’s what all keyloggers are based on. hopefully Light will show us a functional sample if it’s not lost in an archive.

There is a simple, yet rather unelegant solution to this.
Assign your shortcut, but make sure your script is very short and succint so that it doesn’t interupt the users interaction. Then as normal assign it to a shortcut key.

The difficulty would come about when you stop the action. I guess a dotnet timer that you keep on resetting is the best option for this.

[b]else

[/b]You could get lazy and spawn a dialog / delete the dialog


 try (DestroyDialog test) catch (print "First Use")
 
 rollout test "Test Timer"
 	(
 		timer clock "testClock" interval:1000 --tick once a second
 		on clock tick do
 			(
 				print "Executing final action"
 				DestroyDialog test
 			)
 	)
 print "Executing intermediary action"
 createDialog test
 
Page 3 / 3