Can't make example program run...

May 13, 2012 at 10:06 PM
Edited May 13, 2012 at 10:14 PM

I'm new to C# and I want to make use of the hook for a tool i make for Microsoft Touch Mouse . I don't need directions of how to do this or that but I'm trying to make for hours now the example program run in Console Application and I can't.I have done many things on my own just by reading other users responses (generally not for the hook here) but I 'm missing something important here . Please tell me what I am doing wrong :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MouseKeyboardActivityMonitor;
using MouseKeyboardActivityMonitor.WinApi;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor.Controls;
using System.Threading;

namespace ConsoleApplication1
     class Program

         private MouseHookListener m_mouseListener;
        // Subroutine for activating the hook
        public void Activate()
            // Note: for an application hook, use the AppHooker class instead
            m_mouseListener = new MouseHookListener(new GlobalHooker());

            // The listener is not enabled by default
            m_mouseListener.Enabled = true;
            // Set the event handler
                m_mouseListener.MouseDownExt += MouseListener_MouseDownExt;
            // recommended to use the Extended handlers, which allow input suppression among other additional information

        public void Deactivate()
         public void MouseListener_MouseDownExt(object sender, MouseEventExtArgs e)
            // log the mouse click
            Console.WriteLine(string.Format("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp));

            // uncommenting the following line with suppress a middle mouse button click
            // if (e.Buttons == MouseButtons.Middle) { e.Handled = true; }
        static void Main()

            Program hook = new Program();


All this program does is to run for 1 sec and then exit with no errors or anything . I have made a breakpoint inside

MouseListener_MouseDownExt(object sender, MouseEventExtArgs e) and it never breaks . I have tried to use a while loop but no response from the hook.

What is it that i am missing here? Shouldn't the hook make a process of it's own and write to console whenever a new mouse message occurs? Do I need a callback function in Main? 

Please tell me it will drive me nuts... Thank you for your time...