Smart HotKey Handler
Smart Hotkey handler to handle the hotkey events in windows application.
Code Snippet:
Please do the following steps to test the smart hot key handler.

1)      Create a new Windows Application from Visual Studio 2008.

2)      Add Smart Hotkey control to Toolbox (if not available) then drag and drop on to your form.

3)      Open your form code file and add following line of code at constructor of the form.

 Code:

this.hotKey1.HotKeyPressed += new SmartHotKey.HotKey.HotKeyEventHandler(hotKey1_HotKeyPressed);

 4)      Add the hotkey press event handler.

 Code:

void hotKey1_HotKeyPressed(object sender, SmartHotKey.HotKeyEventArgs e)

        {

            MessageBox.Show(e.HotKey);

        }

 5)      Register your required hotkeys.

 Code:

      //normal keys

      this.hotKey1.AddHotKey("S");

      this.hotKey1.AddHotKey("A");

       //normal keys with keymodifiers

      this.hotKey1.AddHotKey("Control+Shift+Alt+U");

         this.hotKey1.AddHotKey("Control+Shift+E");

         //function keys

this.hotKey1.AddHotKey("F2");

this.hotKey1.AddHotKey("F9");

 

//function keys with keymodifiers

this.hotKey1.AddHotKey("Shift+F1");

//other keys[Home,End,PageDown,PageUp and Delete]

this.hotKey1.AddHotKey("Shift+End");

this.hotKey1.AddHotKey("End");

6)      Add following line of code inside of the Dispose method.

 Code:

   //remove all keys

 this.hotKey1.RemoveAllKeys();

 //remove specific key

this.hotKey1.RemoveKey("Shift+End"); //you can call this method where ever you want to remove a hotkey.

 7)      Now you test your application.

Last edited Aug 8, 2010 at 9:04 AM by eshock, version 7