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

Method moveMouseToClientArea

utils.cpp:471–495  ·  view source on GitHub ↗

移动鼠标指针到目标窗口的客户区坐标

Source from the content-addressed store, hash-verified

469
470// 移动鼠标指针到目标窗口的客户区坐标
471bool Utils::moveMouseToClientArea(HWND hwnd, int x, int y) {
472 if (hwnd == nullptr || !IsWindow(hwnd)) {
473 return false;
474 }
475
476 QMutexLocker locker(&m_locker);
477
478 // 将客户区坐标转换为屏幕坐标
479 POINT clientPoint = { x, y };
480 if (!ClientToScreen(hwnd, &clientPoint)) {
481 qWarning() << "Failed to convert client area coordinates to screen coordinates.";
482 return false;
483 }
484
485 // 使用 SetCursorPos 将鼠标移动到目标位置(屏幕坐标)
486 if (!SetCursorPos(clientPoint.x, clientPoint.y)) {
487 qWarning() << "Failed to move mouse to target position.";
488 return false;
489 }
490
491 qDebug() << "Mouse moved to client area coordinates: ("
492 << x << ", " << y << ")";
493
494 return true;
495}
496
497bool Utils::clickWindowClient(HWND hwnd) {
498 if(hwnd == nullptr || !IsWindow(hwnd)){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected