Exemple #1
0
        public bool start()
        {
            bool succ = true;

            if (m_nativeHookPtr == IntPtr.Zero)
            {
                m_managedCallbackObject = new Win32Util.LowLevelMouseProc(interceptInput); //keep reference to callback so its not garbage collected!
                m_nativeHookPtr         = Win32Util.registerLowLevelMouseCallback(m_managedCallbackObject);
                succ = (m_nativeHookPtr != IntPtr.Zero);
                Debug.Assert(succ == true, "Error adding the input hook!");
            }
            else
            {
                succ = false;
                Debug.Assert(succ == true, "Trying to add hook while previous one still exists!");
            }
            Console.WriteLine("Input hook started.");
            return(succ);
        }