private void Form1_Load(object sender, EventArgs e) { MouseMonitor mouseMonitor = new MouseMonitor(this.Handle, 100); mouseMonitor.Start(); mouseMonitor.MouseMovedWithinSharedWindow += mouseMonitor_MouseMovedWithinSharedWindow; }
// Just sample event bind to update window title with the coords we pass, updates the window title with it lol void mouseMonitor_MouseMovedWithinSharedWindow(object sender, MouseMonitor.MouseArgs e) { try { Invoke(new Action(() => Text = "Mouse is at " + e.X + "x" + e.Y + ".")); } catch { // Ignore error that happens if we close form when its trying to update cuz its disposed } }