public void DrawAccessibleObjectLocation(WinTypes.MouseHookStruct ml) { var accList = listBoxAccObjects.DataSource as IList <AccessibleObject>; if (accList == null) { return; } AccessibleObject q = accList.SingleOrDefault(p => (p.Location.Left >= ml.pt.x) && (p.Location.Top >= ml.pt.y) && (p.Location.Right <= ml.pt.x) && (p.Location.Bottom <= ml.pt.y) ); if (q != null) { listBoxAccObjects.SelectedItem = q; } }
public static int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { _currentSelection = (WinTypes.MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(WinTypes.MouseHookStruct)); if (nCode < 0) { return(NativeMethods.CallNextHookEx(hHook, nCode, wParam, lParam)); } String strCaption = "x = " + _currentSelection.pt.x.ToString("d") + " y = " + _currentSelection.pt.y.ToString("d"); var frm = ActiveForm as MainForm; //frm.DrawAccessibleObjectLocation(_currentSelection); if (frm != null) { frm.toolStripCoord.Text = strCaption; } return(NativeMethods.CallNextHookEx(hHook, nCode, wParam, lParam)); }