/// <summary> /// 跟随当前鼠标位置获取句柄信息 /// </summary> private void GetMousePoint() { _hwndInfor = new MousePointHwndInfor(); while (true) { if ((GetKeyState(VK_LBUTTON) & 0x80) == 0x80) { //当前句柄 _hwndInfor.MousePoint = Control.MousePosition; _hwndInfor.CurrentHwnd = mydm.GetPointWindow(_hwndInfor.MousePoint.X, _hwndInfor.MousePoint.Y);//获取句柄 _hwndInfor.CurrentHwndTitle = mydm.GetWindowTitle(_hwndInfor.CurrentHwnd); _hwndInfor.CurrentHwndClassName = mydm.GetWindowClass(_hwndInfor.CurrentHwnd); _hwndInfor.HwndProcessPath = mydm.GetWindowProcessPath(_hwndInfor.CurrentHwnd); //父窗体句柄 _hwndInfor.ParentHwnd = mydm.GetWindow(_hwndInfor.CurrentHwnd, 0); _hwndInfor.ParentTitle = mydm.GetWindowTitle(_hwndInfor.ParentHwnd); _hwndInfor.ParentClassName = mydm.GetWindowClass(_hwndInfor.ParentHwnd); //顶层窗体句柄 _hwndInfor.TopFromHwnd = mydm.GetWindow(_hwndInfor.CurrentHwnd, 7); _hwndInfor.TopFromTitle = mydm.GetWindowTitle(_hwndInfor.TopFromHwnd); _hwndInfor.TopFromClassName = mydm.GetWindowClass(_hwndInfor.TopFromHwnd); _hwndInfor.HwndRect = GetHwndRec(_hwndInfor.CurrentHwnd); SetFormSize(_hwndInfor.HwndRect); } else { break; } Thread.Sleep(100); } this.Invoke(new Action(() => { this.DialogResult = DialogResult.Yes; })); }
public int GetPointWindow(int x, int y) { return(dm.GetPointWindow(x, y)); }