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. Global KeyboardHooks and WiondowsKeyboardHooks

Global KeyboardHooks and WiondowsKeyboardHooks

Scheduled Pinned Locked Moved C#
csharphelpquestioncomtutorial
3 Posts 2 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.
  • N Offline
    N Offline
    nemopeti
    wrote on last edited by
    #1

    Hi everyone, I have made a c# application (from the article: Global System Hooks in .NET By Michael Kennedy link) that installs a systemwide keyboard hook. This application emulate mouse clicks when specified key pressed. It's work fine, only a little problem with it: When keypess occures, my app hooks it, and Windows hoo too. How can I told windows not to do that? Example: I set the 0 key to do left mouse click, when I press 0 in a textbox or in TotalCommander the click occures, and a 0 character appears in the textbox too :sigh: Hope somebody can help me :-> PS: Sorry about my english

    A 1 Reply Last reply
    0
    • N nemopeti

      Hi everyone, I have made a c# application (from the article: Global System Hooks in .NET By Michael Kennedy link) that installs a systemwide keyboard hook. This application emulate mouse clicks when specified key pressed. It's work fine, only a little problem with it: When keypess occures, my app hooks it, and Windows hoo too. How can I told windows not to do that? Example: I set the 0 key to do left mouse click, when I press 0 in a textbox or in TotalCommander the click occures, and a 0 character appears in the textbox too :sigh: Hope somebody can help me :-> PS: Sorry about my english

      A Offline
      A Offline
      ahmad2x4
      wrote on last edited by
      #2

      Hi, I think you can download the Full Source of that article and make some changes on it. and recompile it. In SystemHookCore.cpp at InternalKeyboardHookCallback function you should mark last line and add return 1; instead of that line:static LRESULT CALLBACK InternalKeyboardHookCallback(int code, WPARAM wparam, LPARAM lparam) { if (code < 0) { return CallNextHookEx(hookKeyboard, code, wparam, lparam); } if (UserKeyboardHookCallback != NULL && !keyboardFilter.IsFiltered((int)wparam)) { UserKeyboardHookCallback(code, wparam, lparam); } return 1; // return CallNextHookEx(hookKeyboard, code, wparam, lparam); }
      But I think it is a rapid solution. in addition you should add some mechanism in other class to check in application level that you want to take this action on this character or not. Ahmadreza Atighechi

      N 1 Reply Last reply
      0
      • A ahmad2x4

        Hi, I think you can download the Full Source of that article and make some changes on it. and recompile it. In SystemHookCore.cpp at InternalKeyboardHookCallback function you should mark last line and add return 1; instead of that line:static LRESULT CALLBACK InternalKeyboardHookCallback(int code, WPARAM wparam, LPARAM lparam) { if (code < 0) { return CallNextHookEx(hookKeyboard, code, wparam, lparam); } if (UserKeyboardHookCallback != NULL && !keyboardFilter.IsFiltered((int)wparam)) { UserKeyboardHookCallback(code, wparam, lparam); } return 1; // return CallNextHookEx(hookKeyboard, code, wparam, lparam); }
        But I think it is a rapid solution. in addition you should add some mechanism in other class to check in application level that you want to take this action on this character or not. Ahmadreza Atighechi

        N Offline
        N Offline
        nemopeti
        wrote on last edited by
        #3

        Thank's a lot! It's works fine ;) Can you tell me, how can I modify the ManagedHook or HookCore project to tell them witch cases makes this return 1 trick, and witch not. So how can I tell to the class from my C# app to do the return 1 action when my defined keys pressed, and otherwise do the normal action? I think i shoud add somethink like this: List l; Than I add my specila keys to the list, and every time keypress occures I search the list for the actual key, when I find it, do the return 1... Sorry for my stupid questions, but i not familiar with dll manipulation :sigh: I trí to modify SystemHookCore.cpp, and add a method, and a global witch set/store the keycodes, witch is exclude from system hooks. also modify the, managedhooks class, rebuild all, but when I start my app get error: "Entry point(my new function name) was nt found on systemhook.dll" :sigh: Thank's for help! -- modified at 10:29 Sunday 21st May, 2006

        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