Lesson 7–Control Your Mouse Cursor with Kinect SDK

programmingI’m really loving the Christmas holiday season at the moment. It has gave me so much time to do things with the Kinect I never thought I could do. I remember when the Kinect SDK originally came out and I found a Cursor online which was nice and packaged for the Kinect SDK. The thing that bugged was that it didn’t come with any real code. You couldn’t see what was going on behind it.

At last! I figured out how to get the Kinect to use your hand as a cursor. Once I get some of the minor details fixed in my voice recognition I’m excited about making some really great apps. It means that applications aren’t just limited to the SDK anymore! You could make flash games and use the cursor. You could say “pen down”, then draw a picture and say “pen up” to stop. I’m really excited about these opportunities.

This lesson was a little more tricky with the coding, which is why I have included a finished example and a blank example for you to try it yourself. Click here to download both the files.

The YouTube video below is available in HD so you should be able to work out the code without any issues. Hope it helps.

Kinect SDK–Mouse Cursor–How To….

About Raymond David James Chambers

I am the Lead teacher of computing at Brooke Weston Academy in Corby Northamptonshire. Previously I was the head of IT/Computing at Uppingham Community College. In 2015 I won the Gold National Teaching award for Innovative use of technology. I also won the 2015 Young Game Bafta - Mentor award. I'm keen to help students achieve their best and like to give them opportunities to do this. I have a passion for teaching and I enjoy meeting other people and sharing their ideas. I have a keen interest in games development as well as developing the use of ICT in classrooms across the curriculum. In my spare time I teach Irish dancing. I have been Irish dancing since I was 11. My highest position was 14th at the world championships 3 years running and 2nd at the Great Britain Championships in 2006.
This entry was posted in Education, Kinect, Kinect SDK, Kinect Tutorials and tagged , , , , , , , , . Bookmark the permalink.

13 Responses to Lesson 7–Control Your Mouse Cursor with Kinect SDK

  1. Pingback: Interesting Links 02 January 2012 | MSDN Blogs

  2. Joe says:

    Here is Joe again!
    I have try this code in my project and wonder if I can add the mouse wheel event?
    something using the distance between HandRight.Position and HandLeft.Position to replace the e.delta value to zoom in and out of a image
    I have already had the distance but cant figure how to send this into a mousewheel event.
    Any hint?
    Thanks again!

  3. novita says:

    Hi.. I’m beginner and I have try your tutorial. but I don’t too understand about the mouse event. do u have any tutorial or explanation about this? and I also want to try the same thing as Joe said , to zoom in and zoom out image..

    your lesson very helpful. thank you so much! 🙂

    • raychambers says:

      Unfortunately there is no extra tutorial for the mouse event, however…. I can explain something about the code… Each time you add a new mouse event, you will probably notice the bit at the top you included with the parameters 0x0003 etc…. when you set up the mouse event you give it a name like right click, left click…. the 0x0003 number is a virtual key code. It sends a replica message. Here are some examples here:

      VK_LBUTTON 01 Left mouse button – 0x0001
      VK_RBUTTON 02 Right mouse button – 0x0002
      VK_CANCEL 03 Control-break processing – 0x0003
      VK_MBUTTON 04 Middle mouse button (three-button mouse) 0x0004

      http://msdn.microsoft.com/en-us/library/ms927178.aspx here are a lot of virtual key codes. Hope this helps a little bit

  4. hello there m8
    thanks alot for the great tutorial

    but i have a question, what kind of events can i do for the click ?
    i mean can i do the gesture forward for the click ?

    if you can please give me any gesture that is usable for a click


  5. abdalruhman says:

    hello ,

    how to update the code to work with the new sdk ?


  6. fajer khajah says:


    I am studying information system

    and for my capstone I need to control the mouse cursor with Kinect my coding is working but the cursor is always stuck in the middle and go a little to left and a little to right

    Also I downloaded your code to try it but its not opening with My microsoft visual basic 2010 can you tell me what version to use

    thank you alot


    Fajer Khajah

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s