0

I am implementing this code that is listed on this website...

http://www.codeproject.com/Articles/117657/InputManager-library-Track-user-input-and-simulate?msg=4509471#xx4509471xx

The code itself is in .NET however his explaination he wrote in C? no idea why, but I need to know how to convert this into .NET

KeyboardHook.KeyDown += new KeyboardHook.KeyDownEventHandler(KeyboardHook_KeyDown);
KeyboardHook.KeyUp += new KeyboardHook.KeyUpEventHandler(KeyboardHook_KeyUp);
KeyboardHook.InstallHook();

I get an error that says "'Public Shared Event KeyDown(vkCode As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event."

Of course i get this for both the KeyDown and KeyUp version. Can anyone help please?

I've tried doing

AddHandler KeyboardHook.KeyDown, AddressOf KeyboardHook_KeyDown 

but it doesn't trigger this whenever the keydown actually happens.

eqiz
  • 1,521
  • 5
  • 29
  • 51
  • Don't use C# syntax in a VB.NET program. The code from that site has the typical problem, there's no meaningful review so bad code is allowed to live on without getting fixed. The way he uses SetWindowsHookEx() stopped working in .NET 4.0. No error checking either so it just fails without diagnostic. Workaround is [described here](http://stackoverflow.com/a/3684292/17034). – Hans Passant Sep 12 '13 at 18:08
  • I'm extremely confused on why you said what you did. What does your explanation have ANYTHING to do with the question that was asked? It has nothing to do with .NET 4.0 or anything in question. the SetWindowsHookEx() isn't even in question here either. If you don't know how to add an event handler correctly or know how to use Raise Event in this circumstance then don't respond! – eqiz Sep 13 '13 at 19:24

0 Answers0