发送的时候要带坐标吧。 lParam The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
mouse_event (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, rc.left, rc.top, 0, 0 )
mouse_event (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, rc.left, rc.top, 0, 0 )
发送的时候要带坐标吧。
lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
代码如下:HTREEITEM Child61 = TreeView_GetChild(htree, Child6); //(火拼麻将)
BOOL bSel=(BOOL)::SendMessage(htree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)Child61);
TreeView_EnsureVisible(htree, Child61);
DWORD pid = 0;
GetWindowThreadProcessId(htree,&pid);
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,true,pid);
RECT *prect=(RECT*)VirtualAllocEx(hProcess, NULL, sizeof(RECT), MEM_COMMIT, PAGE_READWRITE);
RECT rect={0};
unsigned long n=0;
*(HTREEITEM*)&rect = Child61;
WriteProcessMemory(hProcess, prect, &rect, sizeof(RECT), NULL);
::SendMessage(htree, TVM_GETITEMRECT, (WPARAM)FALSE, (LPARAM)prect);
ReadProcessMemory(hProcess,prect,&rect,sizeof(RECT),&n);
POINT pt={0};
pt.x = rect.left + (rect.right-rect.left)/2;
pt.y = rect.top + (rect.bottom-rect.top)/2;
::ClientToScreen(htree,&pt); //鼠标事件
SetCursorPos(pt.x, pt.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0,0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0,0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0,0); //释放内存
CloseHandle(hProcess);
VirtualFreeEx(hProcess, prect, 0, MEM_RELEASE);