模拟双击其它进程窗口中的CListCtrl控件的某一项

之前写过一个模拟点击本进程窗口CListCtrl控件的某一项,请参考这里。

HWND hWnd = ::FindWindow(NULL, _T("XXX")); if(hWnd) { HWND hList = ::FindWindowEx(hWnd, NULL, _T("SysListView32"), NULL); if(hList) { DWORD PID = 0; ::GetWindowThreadProcessId(hList, &PID); HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID); if(hProcess) { RECT rc = {0}; RECT* pRect = NULL; pRect = (RECT*)::VirtualAllocEx(hProcess, NULL, sizeof(RECT), MEM_COMMIT, PAGE_READWRITE); if(NULL == pRect) { ::CloseHandle(hProcess); return ; } // 这里得到CListCtrl控件的item = 2的RECT区域,即CListCtrl控件的第三行 ::SendMessage(hList, LVM_GETITEMRECT, 2, (LPARAM)pRect); DWORD dwRead = 0; ::ReadProcessMemory(hProcess, pRect, &rc, sizeof(RECT), &dwRead); POINT pt = {0}; pt.x = rc.left + (rc.right - rc.left) / 2; pt.y = rc.top + (rc.bottom - rc.top) / 2; ::SendMessage(hList, WM_LBUTTONDBLCLK, MK_LBUTTON, MAKELPARAM(pt.x, pt.y)); ::VirtualFreeEx(hProcess, pRect, sizeof(RECT), MEM_RELEASE); ::CloseHandle(hProcess); } } }

你可能感兴趣的:(null,Access)