AutoLeap: Leap Motion Module - AHK control with your hands!
Posted: 09 Dec 2014, 16:45
If you don't already know what a Leap Motion Controller is, then watch this video: http://www.youtube.com/watch?v=_d6KuiuteIA
This is an exciting, new piece of technology that has lots of potential. The Leap SDK supports C++, Java, Unity, CSharp, and a few other prominent languages. That's great, but it doesn't support AutoHotkey! The goal of AutoLeap is to do just that.
And it's already successful. The first AutoHotkey-based program went live on Airspace a few months ago (developed by yours truly). You can view the application here: https://airspace.leapmotion.com/apps/wi ... er/windows
This is a two-layer module with a small C++ application being the inner layer and AutoHotkey (AutoLeap.ahk) being the outer layer. The inner layer has a callback in a thread from msvcr120.dll. The callback is invoked when a "pointable" object comes into view of the controller. The rate at which the callback is invoked is directly dependent upon your frame rate, meaning that if you get 60 FPS then the callback is called every ~16.67ms (1000 ms / 60 frames). This is important to understand because this means your script should take no longer than 16.67 (or 1000 ms / FrameRate ) to execute it's "OnFrame" events or else lag will occur.
Q: Couldn't the lag be avoided by using a buffer?
A: One day, I hope so. Currently the limitation revolves around the fact that the C++ application uses SendMessage (which waits for a return value before proceeding) to forward data to the AHK script (AutoLeap).
Included in this post is a sample which demonstrates various ways to use this Leap Motion Controller with AutoHotKey. It's important to know the basics, and here they are:
Fork the AHK module here: https://github.com/Aatoz/AutoHotkey/tre ... s/AutoLeap
Download the AHK sample, AutoLeap module (including C++ forwarder) here: https://www.dropbox.com/s/z366t0mjlu6ju ... e.zip?dl=0
Here's an exhaustive list of data available through rLeapData, but it may become dated as the module is developed further.
This is an exciting, new piece of technology that has lots of potential. The Leap SDK supports C++, Java, Unity, CSharp, and a few other prominent languages. That's great, but it doesn't support AutoHotkey! The goal of AutoLeap is to do just that.
And it's already successful. The first AutoHotkey-based program went live on Airspace a few months ago (developed by yours truly). You can view the application here: https://airspace.leapmotion.com/apps/wi ... er/windows
This is a two-layer module with a small C++ application being the inner layer and AutoHotkey (AutoLeap.ahk) being the outer layer. The inner layer has a callback in a thread from msvcr120.dll. The callback is invoked when a "pointable" object comes into view of the controller. The rate at which the callback is invoked is directly dependent upon your frame rate, meaning that if you get 60 FPS then the callback is called every ~16.67ms (1000 ms / 60 frames). This is important to understand because this means your script should take no longer than 16.67 (or 1000 ms / FrameRate ) to execute it's "OnFrame" events or else lag will occur.
Q: Couldn't the lag be avoided by using a buffer?
A: One day, I hope so. Currently the limitation revolves around the fact that the C++ application uses SendMessage (which waits for a return value before proceeding) to forward data to the AHK script (AutoLeap).
Included in this post is a sample which demonstrates various ways to use this Leap Motion Controller with AutoHotKey. It's important to know the basics, and here they are:
- Initialize an AutoLeap object like this: vLeap := new AutoLeap("LeapSample_MsgHandler")
- Callback must have the following parameters: LeapSample_MsgHandler(sMsg, ByRef rLeapData, ByRef rasGestures, ByRef rsOutput)
- rLeapData is your friend. It is an EasyIni object with sections for all hands and fingers within view of the controller.
Fork the AHK module here: https://github.com/Aatoz/AutoHotkey/tre ... s/AutoLeap
Download the AHK sample, AutoLeap module (including C++ forwarder) here: https://www.dropbox.com/s/z366t0mjlu6ju ... e.zip?dl=0
Here's an exhaustive list of data available through rLeapData, but it may become dated as the module is developed further.
Spoiler