Losing the global mouse handler after a few seconds

Jan 31, 2012 at 5:38 PM


Im making an interactive application where the user via touch should be able to interact with the application. The administrator has a possibility to set the interactive application as a web page - thus im not getting normal mouse events since this is a webbrowser. I need the mouse events to refresh my timeout for when the system should go into "pause" mode - e.g. show an advert instead of the interactive ui. Global hooks is the only solution i see that allows me to do this on a webbrowser.

My problem is that it works fine when i dont load any user controls in my app. But when i load the first user control - it seem to drop the global mouse hook. Any idea on why this is happening?

Thank you in advance.



Jan 31, 2012 at 5:49 PM

Figured it out, it is being garbage collected. First i had this code:


MouseHookListener mouseListener = new MouseHookListener(new GlobalHooker());
mouseListener.Enabled = true; 
mouseListener.MouseDownExt += new EventHandler(mouseListener_MouseDownExt);


Then it only worked until it was being garbage collected. Then i made a

private MouseHookListener mouselistener;
in my class and it is now being referenced througout the lifetime of my application. Now it works perfectly.