MCPcopy Create free account
hub / github.com/Hashiao/wuwaBackendTool / middleClickWindowClientArea

Method middleClickWindowClientArea

utils.cpp:522–551  ·  view source on GitHub ↗

模拟鼠标中键点击目标窗口的客户区坐标

Source from the content-addressed store, hash-verified

520
521// 模拟鼠标中键点击目标窗口的客户区坐标
522bool Utils::middleClickWindowClientArea(HWND hwnd, int x, int y) {
523 if(hwnd == nullptr || !IsWindow(hwnd)){
524 return false;
525 }
526
527 QMutexLocker locker(&m_locker);
528 // 将客户区坐标转换为屏幕坐标
529 POINT clientPoint = { x, y };
530 if (!ClientToScreen(hwnd, &clientPoint)) {
531 qWarning() << "Failed to convert client area coordinates to screen coordinates.";
532 return false;
533 }
534
535 // 如果 x, y 是“客户区坐标”,则直接组合到 lParam
536 // MAKELPARAM 的低 16 位是 X 坐标,高 16 位是 Y 坐标
537 LPARAM lParam = MAKELPARAM(x, y);
538
539 // 发送鼠标中键按下消息
540 PostMessage(hwnd, WM_MBUTTONDOWN, MK_MBUTTON, lParam);
541 Sleep(50); // 给消息处理留一点缓冲时间
542
543 // 发送鼠标中键松开消息
544 PostMessage(hwnd, WM_MBUTTONUP, 0, lParam);
545 Sleep(50);
546
547 qDebug() << "Simulated middle click at client area coordinates: ("
548 << x << ", " << y << ")" ;
549
550 return true;
551}
552
553// 实现 cv::Mat 转 QImage
554QImage Utils::cvMat2QImage(const cv::Mat& mat) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected