What it takes is called
Global Windows Hook. Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx[
^].
The key here is
global (please see the explanation of
global starting from the first MSDN library referenced above). It makes the problem more difficult: you won't be able to just use P/Invoke and call hook methods in your VB.NET application. According to Microsoft documentation, you will need to install the hooks in the native DLL. If you are using C++, it will be suitable for writing such DLL. And then your application can use this DLL to do the rest.
It would be very beneficial to do it in a
mixed-mode (managed + unmamaged) C++/CLI project where you can freely mix managed .NET code ("ref" managed types) with the unmanaged:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[
^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[
^],
http://www.gotw.ca/publications/C++CLIRationale.pdf[
^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[
^].
Note that the applications based on hook are well above average in terms of difficulty of development, especially debugging.
—SA