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 / C++ / MFC
  4. how to get control of keyboard and mouse?

how to get control of keyboard and mouse?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorial
4 Posts 3 Posters 0 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.
  • T Offline
    T Offline
    ThinkingPrometheus
    wrote on last edited by
    #1

    hiho@ll i just need to sniffer what the user enters and the exact mouse events the user makes (mouse click (which button), mouse moves) and i need to send such events to the OS (windows) the problem: 1. i really have no idea how this could work 2. how can i send such events to the OS on an independent way this means, i just don't know which window is focused (which application gets the events) and that's also what i want! i want to send these events to the OS which processes it for the right application! i don't want to know which app is focused because it's not necessary for what i need to do! (well, later maybe it will be necessary but that's another topic/post) thx@ll

    R V 2 Replies Last reply
    0
    • T ThinkingPrometheus

      hiho@ll i just need to sniffer what the user enters and the exact mouse events the user makes (mouse click (which button), mouse moves) and i need to send such events to the OS (windows) the problem: 1. i really have no idea how this could work 2. how can i send such events to the OS on an independent way this means, i just don't know which window is focused (which application gets the events) and that's also what i want! i want to send these events to the OS which processes it for the right application! i don't want to know which app is focused because it's not necessary for what i need to do! (well, later maybe it will be necessary but that's another topic/post) thx@ll

      R Offline
      R Offline
      RicoH
      wrote on last edited by
      #2

      Hi, to log the users keyboard and mouse activity you'll have to take a look at the 'SetWindowsHookEx' function. This allows you to set system-wide keyboard and mouse hooks which will receive all keyboard and mouse activity. Once you have captured the events you can make use of the 'SendInput' function to send the events to the OS which will handle them as if you were really typing or moving the mouse... Don't think you are, know you are...

      1 Reply Last reply
      0
      • T ThinkingPrometheus

        hiho@ll i just need to sniffer what the user enters and the exact mouse events the user makes (mouse click (which button), mouse moves) and i need to send such events to the OS (windows) the problem: 1. i really have no idea how this could work 2. how can i send such events to the OS on an independent way this means, i just don't know which window is focused (which application gets the events) and that's also what i want! i want to send these events to the OS which processes it for the right application! i don't want to know which app is focused because it's not necessary for what i need to do! (well, later maybe it will be necessary but that's another topic/post) thx@ll

        V Offline
        V Offline
        vishalmore
        wrote on last edited by
        #3

        Global hook is the solution to your problem, but hooks are not stable and are specifically used for debugging purposes. While implementing the global hooks be curious O.W it would screw entire system. Have a look at the API's SetWindowsHookEx, UnhookWindowsHookEx etc... You can get tons of information about hooks on codeproject and online MSDN. All the best ! Cheers, Vishal

        T 1 Reply Last reply
        0
        • V vishalmore

          Global hook is the solution to your problem, but hooks are not stable and are specifically used for debugging purposes. While implementing the global hooks be curious O.W it would screw entire system. Have a look at the API's SetWindowsHookEx, UnhookWindowsHookEx etc... You can get tons of information about hooks on codeproject and online MSDN. All the best ! Cheers, Vishal

          T Offline
          T Offline
          ThinkingPrometheus
          wrote on last edited by
          #4

          i'll have a look thx!

          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