First of all, although you can contribute to the world by joining an existing project, I say: where is it fun? Therefore, if you do this in order to learn and have fun, then you should definitely go with him.
Global keys :
Yes, it is possible by connecting to the Windows message path. Import dll is required for user32.dll and kernel32.dll. I previously did something like this:
using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace DevBoard.App { internal class InterceptKeys { #region Delegates public delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); #endregion private const int WH_KEYBOARD_LL = 13; private const int WM_KEYDOWN = 0x0100; public static IntPtr SetHook(LowLevelKeyboardProc proc) { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return SetWindowsHookEx(WH_KEYBOARD_LL, proc,GetModuleHandle(curModule.ModuleName), 0); } } [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool UnhookWindowsHookEx(IntPtr hhk); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr GetModuleHandle(string lpModuleName); } }
Search
If you want to do some advanced index search, you can look at Lucene.Net
Happy coding! :)
Luhmann
source share