The Library (dll / assembly)

You need Microsoft .NET Framweork 4.0 or superior to use this library.

You can download the library installer at the bottom of this page.

There is a demo solution with source code, on the library install path.

The installer will create a start menu programs folder, named JohannaSoft from where you can access the installation folder and the documentation.

If you want to add the library to your Global Assembly Cache (GAC), from a command line on the library folder:

    gacutil -i KeyboardHook.dll

If you want to uninstall the library from your Global Assembly Cache (GAC), from a command line on the library folder:

    gacutil -u KeyboardHook

Remember to do both operations with administrative privileges.

Other than that, you can reference the library from your project, selecting it from it's installation path.

To use the library, from your project:

  • Add new reference to KeyboardHook

  • Define the method for the event. Taken from the example: 

        /// updates the textbox with the cparured character(s) from the
        /// low level keyboard hook
        /// </summary>
        /// <param name="s">ProcessKeyCapture containing the origin window process id and the captured char(s)</param>
        void updateText(JohannaSoft.KeyboardHook.ProcessKeyCapture s)
        {
            //return key pressed (\r), we make just new line
            if (s.CapturedString.Equals("\r"))
                s.CapturedString = "ENTER_KEY\r\n";
            textBox1.AppendText(String.Format("Window Process Id :{0} Char(s) :{1}\r\n", s.WindowProcessId, s.CapturedString));
          }


  • Assing the event method to the event in the keyboard hook library :
        JohannaSoft.KeyboardHook.KeybHookLib.kb_event += new JohannaSoft.KeyboardHook.KeybHookLib.KBEventHandler(updateText);
  • To start the hook, we use:
        JohannaSoft.KeyboardHook.KeybHookLib.setKeyboardHook();
  • To stop using the hook:
        JohannaSoft.KeyboardHook.KeybHookLib.UnsetsetKeyboardHook();


The object ProcessKeyCapture has  only two properties :


  • WindowProcessId : the id of the windows process where the user pressed the keyboard key
  • CapturedString : The character or characters captured

*If the user press RETURN the CapturedString value is `\r'.


The gadget spec URL could not be found


ċ
KeyboardHookLibSetup.msi
(1090k)
Johannasoft Software,
Sep 10, 2014, 1:38 AM
Comments