Tuesday, February 28, 2017

windowsdesktop/KeyDown Event

Download

Introduction

Using some applications, you are faced with some shortcut keys, for example, after pressing a key displays a help screen, when you press any other key functionality is done. But have you ever asked how it is done?

This functionality is done via the KeyDown event, which is an event of the form design. It is possible to create shortcuts in a simple button press, linking functionality on each key.

 

Description

The code was done in C# Visual Studio 2010 and it show how the form's event works. In the attached project you can verify in the class Form1.cs the KeyDown working with 3 keys: A key, ENTER key, F1 key.

This is used to create some shortcuts keys in the application, facilitating to the user see the help window, for example.

To do it, it is necessary to change the KEYPREVIEW value. This is a property of the form, that allow keys to trigger an event. From this, it is possible to code the KeyDown event.

The KeyDown event is triggered when the key is being pressed, different of the KeyUp, that is triggered when the key is being released.

I preffer use the KeyDown event because is faster to the user, because in few moments the functionality is done and the user do not need to wait the key being released.

Look in the code below how it works.

C#
Editar Script|Remove
        /// <summary>           /// KeyDown event.           /// </summary>           private void Form1_KeyDown(object sender, KeyEventArgs e)           {               // If the ENTER key was pressed, the code below is executed.               if (e.KeyCode == Keys.Enter)               {                   MessageBox.Show("The key \"ENTER\" was pressed""Success!");               }                  // If the F1 key was pressed, the code below is executed.               else if (e.KeyCode == Keys.F1)               {                   MessageBox.Show("Key \"F1\" was pressed""Success!");               }                  // If the A key was pressed, the code below is executed.               else if (e.KeyCode == Keys.A)               {                   MessageBox.Show("The key \"A\" was pressed""Success!");               }           }

Source Code Files

  • The code above is into the class Form1.cs;
  • To see the code working, just execute the project.

windowsdesktop/Kinect Multipoint Sample

Download

Introduction

This project entails making the kinect sdk work with the multi-point mouse sdk and mouse mischief and other multimouse applicartions (its really a multimouse implementation of kinect mouse). Allowing the use of a kinect as multiple mice. (4 - 6 people per kinect * number of people in classroom).

This project is for an educational classroom/non-profit usage only and full source disclosure setting until status changed on dsf runtime being redistributable for commerical purposes.

The kinect needs to be used for more then just gaming right? Well i have started a project that allows people to use the multi-point sdk with the kinect sdk and mouse mischief powerpoint add-on.

Note: As the project gets towards completion i will distribute builds of the exe files for people to download.

This project is designed for the microsoft kinect for sdk v1/multi-point sdk/mouse mischief powerpoint for windows. Please download them before proceeding to help with the project as in the future or now you would need them to see if the code is working.
Update(2/7/2013): I will be posting a visual studio 2012 update to the source I have posted so far in which the code overall is more complete for testing.

Building the Sample

no you just need to compile for your platform the source x86 (32-bit) and x64 (64-bit)

Usage of Sample

use shell in vb.net to softhehcicfg /REMOVE and INSTALL under the program files\dsf\softehci folder.

 input report examples for device:

For example, 

InputReport(0) = CByte(1)

InputReport(1) = CByte(0)

InputReport(2) = CByte(0)

InputReport(3) = CByte(0)

InputReport(4) = CByte(0)

 The mouse is down in this sample and the mouse is at x,y coordinates (0,0).

For reference on the dsf code:   

BUTTON  X  Y  WHEEL PAN

InputReport(0) = CByte(mouse click converted to hex here) - Button state of mouse (0- down and 1- up but you already knew that)

InputReport(1) = CByte(x coordinates converted to hex here) - x coordinates of mouse on screen (relative)
InputReport(2) = CByte(y coordinates converted to hex here) - y coordinates of mouse on screen (relative)

InputReport(3) = CByte(0) - default value for wheel that never changes. - mouse wheel value only for advanced coders/users that want to change mouse wheel value.

InputReport(4) = CByte(0) - default value for pan that never changes. - mouse screen pan values for advanced coders/users only!

Also, remember for button state must  go up and down states both for mouse_click subs in vb.net or other multimouse programs to function/register it as a click (which is you holding down the mouse and releasing) properly.

 

Excuse me if i get a little rough in this conversation with the wdk guys but here is a link to where they divulge more about the input report and i believe talked about left and right mouse clicking but not for sure:

http://social.msdn.microsoft.com/Forums/ar/wdk/thread/3470662f-e51e-424d-b540-25975a56f2c8

I think 0 and 1 are the states for the left mosue click but im not for sure about a right mouse click but this is still a work in progress.

Thought i would post the above for anyone wondering how to test the mouse emulation script.

Note: i could put command line parameters for script but is very unstable to work this way.

 For latest documentation or usage please go here:

http://kinectmultipoint.codeplex.com/documentation

Big note: you can emulate other devices with this code with the kinect but only for people who already know the devices input/output at the hardware level. Change the inputreport variable and descriptors in the vbscript to do so for more information refer to dsf documentation on msdn.

 

More Information

please go to http://www.kinectforwindows.org for help/more requirements on kinect sdk installation and downloading of kinect sdk. Might need directx sdk too in addition to kinect requirements.

 

windowsdesktop/Kinect SDK Audio API

Download

Version for Kinect SDK Beta 2 is available here:

http://code.msdn.microsoft.com/Kinect-SDK-Beta2-Wszystkie-ecff4435

Wprowadzenie

Aplikacja, opracowana na potrzeby niniejszego artykułu, posiada zaimplementowaną funkcjonalność rozpoznawania mowy. Po deklaracji kontenera, który będzie służył jako słownik dla trzech słów (red, green, blue) i uruchomieniu aplikacji, każdy dźwięk, zarejestrowany przez sensor Kinect, zostanie poddany procesowi, który będzie miał na celu rozpoznanie odebranego sygnału, a następnie zareagowanie na konkretne słowo. Program pokazuje również, z jaką dokładnością dźwięk został rozpoznany i do którego wzorca ze słownika został on dopasowany.

Poniżej znajduje się opis poszczególnych fragmentów programu, które mają decydujący wpływ na jego funkcjonowanie.

 

C#
Edytuj|Usuń
using (var source = new {
 

 

Powyższy kod pozwala na używanie funkcji, odpowiedzialnych za przetwarzanie dźwięku. Następnie tak utworzonemu obiektowi oraz jego własnościom, należy nadać odpowiednie wielkości, które aktywują przetwarzanie dźwięku oraz startują urządzenie w odpowiednim trybie:

 

C#
Edytuj|Usuń
source.FeatureMode = true;   source.AutomaticGainControl = falsey;
 

 

W kolejnym kroku należy zdefiniować, jakiego języka aplikacja będzie używać do rozpoznawania mowy (w chwili pisania artykułu dostępny był język angielski):

 

C#
Edytuj|Usuń
privateconststring RecognizerId = "SR_MS_en-US_Kinect_10.0");

 

Następnie uruchamiamy silnik rozpoznawania mowy, bazujący na języku, zdefiniowanym wcześniej:

C#
Edytuj|Usuń
using (var sre = new {
 

windowsdesktop/Kinect SDK Audio API c70256ff?localeN

Kinect SDK - Audio API

Aplikacja, opracowana na potrzeby niniejszego artykułu, posiada zaimplementowaną funkcjonalność rozpoznawania mowy.

C# (182.0 KB)
 
 
 
 
 
4 Star
(1)
1,657 times
Add to favorites
11/18/2011
E-mail Twitter del.icio.us Digg Facebook