Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get Keyboard Hooks from a particular application

get Keyboard Hooks from a particular application

Scheduled Pinned Locked Moved C#
comhelp
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    avika
    wrote on last edited by
    #1

    I am trying to get keyboard and mouse hooks. I am able to install hooks in my system and also get the hooks. But i am trying to get hooks from a particular application, so is there any way to get it or it is possible that when i am installing the hooks then i am able to install for a particular application only. I am using the following url as a sample application. http://www.codeproject.com/KB/system/globalsystemhook.aspx Please help me..

    L K 2 Replies Last reply
    0
    • A avika

      I am trying to get keyboard and mouse hooks. I am able to install hooks in my system and also get the hooks. But i am trying to get hooks from a particular application, so is there any way to get it or it is possible that when i am installing the hooks then i am able to install for a particular application only. I am using the following url as a sample application. http://www.codeproject.com/KB/system/globalsystemhook.aspx Please help me..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If you are trying to install global hook,you have to know that .NET Framework doesn't support that :laugh: .You need a native DLL(based of MFC library for example),because .NET assembly doesn't support DLL exports(which are used for LoadLibary native function),required by the global hooks.Read bottom lines of this article.

      Life is a stage and we are all actors!

      A 1 Reply Last reply
      0
      • A avika

        I am trying to get keyboard and mouse hooks. I am able to install hooks in my system and also get the hooks. But i am trying to get hooks from a particular application, so is there any way to get it or it is possible that when i am installing the hooks then i am able to install for a particular application only. I am using the following url as a sample application. http://www.codeproject.com/KB/system/globalsystemhook.aspx Please help me..

        K Offline
        K Offline
        King Julien
        wrote on last edited by
        #3

        you can do this only by using native dlls..... If you already installed the hooks successfully then the task is much simply accomplished by just getting the active application by getting the active window. Get the handle of the ActiveWindow. you can refer this page.link[^] Determine the application from the handle and map the current mouse and keyboard events to this application.

        Have a Happy Coding.....

        A 1 Reply Last reply
        0
        • L Lost User

          If you are trying to install global hook,you have to know that .NET Framework doesn't support that :laugh: .You need a native DLL(based of MFC library for example),because .NET assembly doesn't support DLL exports(which are used for LoadLibary native function),required by the global hooks.Read bottom lines of this article.

          Life is a stage and we are all actors!

          A Offline
          A Offline
          avika
          wrote on last edited by
          #4

          ya i knw .NET Framework doesn't support this. I am using same dll and using this i am able to install hooks and also able to get the events on pressing of keys. But i want to install the hooks for a particular application, so is there any method that give me this functionality or is there any way to get the application name on which we have pressing keys, so that i can do something on events if hooks comes from a particular application.

          1 Reply Last reply
          0
          • K King Julien

            you can do this only by using native dlls..... If you already installed the hooks successfully then the task is much simply accomplished by just getting the active application by getting the active window. Get the handle of the ActiveWindow. you can refer this page.link[^] Determine the application from the handle and map the current mouse and keyboard events to this application.

            Have a Happy Coding.....

            A Offline
            A Offline
            avika
            wrote on last edited by
            #5

            thanks for your reply. I think this will help me ... thanks a lot dear ...

            K 1 Reply Last reply
            0
            • A avika

              thanks for your reply. I think this will help me ... thanks a lot dear ...

              K Offline
              K Offline
              King Julien
              wrote on last edited by
              #6

              :) :) :) :) :) :)

              Have a Happy Coding.....

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups