Vb Net – Low Level Keyboard Hook (Global)

This blog has moved
New location: http://sim0n.wordpress.com/

Posts matching query:
[VB.Net] Keyboard Hook Class
[VB.Net] Mouse Hook Class

13 comments so far

  1. Joel on

    What’s Marshal.GetHINSTANCE ?

    Seems to be undefined.

  2. ih4x on

    Joel, very sorry for the late reply…

    You will need to import:

    Namespace: System.Runtime.InteropServices

  3. Anubhava Dimri on

    Where the Keydown and Keyup event is fire.

    How to check the keypress is fire.

    Thanks
    Anubhava Dimri
    9250168195

  4. greg on

    I tried this(windows vista) and it does not seem to work at all.. This is al ittle new to me but I thing it has something to do with a value of zero always being returned by:
    ‘Installs a Low Level Keyboard Hook
    KeyHookDelegate = New KeyboardProcDelegate(AddressOf KeyboardProc)
    KeyHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyHookDelegate, Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
    Any Ideas?

    • ih4x on

      Probs cos Vista sux :P

  5. Sintoras on

    Just for the record, an a LOT simpler way with the log would be convert.tochar(Keycode) instead of the long if then statements…

  6. Sintoras on

    forget what I said -.-
    no idea why I didn’t realize why you didn’t use it…:D

  7. Broken on

    Uhm, when i do the Private Declare Function CallNextHookEx Lib “user32″ (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer part, it says “End of statement expected”, you know how to fix it? Not so good in visual basic.

    • ih4x on

      if you are just CopyPasting, make sure that the formatting is right. WordPress likes to screw up “’s

  8. xNrGFrEaKx on

    Where do i have to put all if’s and else if’s?

  9. Mark on

    great codes.

    but i have one error :
    Event ‘KeyUp’ cannot be found.
    Event ‘KeyDown’ cannot be found.

  10. Vance Wallace on

    withevents variable does not raise any instance events that are accessible to class form1

  11. Broken on

    I don´t know if you still read this, but i need some help.
    I took the time to read trought this again, and i got a lot few errors, but theres still 2 thats bugging me.

    1: Name “Marshal” is not declared
    (I dont know how to import settings, mind telling me?)
    2:Syntax Error
    (With the following line:
    Handles MyBase.Load
    Its the “Handles” that has the syntax error.)


Leave a reply