MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / sendMousePointClick

Method sendMousePointClick

QKeyMapper/qkeymapper_worker.cpp:4837–4962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4835}
4836
4837void QKeyMapper_Worker::sendMousePointClick(QString &mousepoint_str, int keyupdown, int sendmappingkeymethod)
4838{
4839 static QRegularExpression regex(R"((Mouse-L|Mouse-R|Mouse-M|Mouse-X1|Mouse-X2)(:W)?(:BG)?\((-?\d+),(-?\d+)\))");
4840 QRegularExpressionMatch match = regex.match(mousepoint_str);
4841
4842 if (match.hasMatch()) {
4843 QString mousebutton = match.captured(1);
4844 if (!VirtualMouseButtonMap.contains(mousebutton)) {
4845 return;
4846 }
4847
4848 bool isWindowPoint = !match.captured(2).isEmpty();
4849 bool isPostBG = !match.captured(3).isEmpty();
4850 bool x_ok;
4851 bool y_ok;
4852 int x = match.captured(4).toInt(&x_ok);
4853 int y = match.captured(5).toInt(&y_ok);
4854
4855 if (!x_ok || !y_ok) {
4856 return;
4857 }
4858
4859 if (isWindowPoint) {
4860 QPoint mousepoint(x, y);
4861
4862 if (QKeyMapper::s_CurrentMappingHWND != NULL) {
4863 if (sendmappingkeymethod == SENDMAPPINGKEY_METHOD_SENDMESSAGE || isPostBG) {
4864#ifdef DEBUG_LOGOUT_ON
4865 qDebug().nospace().noquote() << "[sendMousePointClick] SendMessage, postMouseButton(" << mousebutton << ", " << x << ", " << y << ") " << ((keyupdown == KEY_DOWN) ? "KeyDown" : "KeyUp") << " -> " << QKeyMapper::s_CurrentMappingHWND;
4866#endif
4867 postMouseButton(QKeyMapper::s_CurrentMappingHWND, mousebutton, keyupdown, mousepoint);
4868 }
4869 else if (sendmappingkeymethod == SENDMAPPINGKEY_METHOD_FAKERINPUT) {
4870#ifdef FAKERINPUT_SUPPORT
4871 // Convert window coordinates to screen coordinates for FakerInput absolute mouse
4872 POINT screenPoint = { mousepoint.x(), mousepoint.y() };
4873 ClientToScreen(QKeyMapper::s_CurrentMappingHWND, &screenPoint);
4874#ifdef DEBUG_LOGOUT_ON
4875 qDebug().nospace().noquote() << "[sendMousePointClick] FakerInput Window : FakerInputClient_sendAbsoluteMouseButton(" << mousebutton << ", " << screenPoint.x << ", " << screenPoint.y << ") " << ((keyupdown == KEY_DOWN) ? "KeyDown" : "KeyUp") << " -> " << QKeyMapper::s_CurrentMappingHWND;
4876#endif
4877 FakerInputClient_sendAbsoluteMouseButton(mousebutton, screenPoint.x, screenPoint.y, keyupdown, VIRTUAL_MOUSE_POINTCLICK);
4878#endif
4879 }
4880 else {
4881#ifdef DEBUG_LOGOUT_ON
4882 qDebug().nospace().noquote() << "[sendMousePointClick] sendWindowMousePointClick(" << mousebutton << ", " << x << ", " << y << ") " << ((keyupdown == KEY_DOWN) ? "KeyDown" : "KeyUp") << " -> " << QKeyMapper::s_CurrentMappingHWND;
4883#endif
4884 sendWindowMousePointClick(QKeyMapper::s_CurrentMappingHWND, mousebutton, keyupdown, mousepoint);
4885 }
4886 }
4887
4888 if (QKeyMapper::getSendToSameTitleWindowsStatus()) {
4889 for (const HWND &hwnd : std::as_const(QKeyMapper::s_last_HWNDList)) {
4890 if (QKeyMapper::s_CurrentMappingHWND == hwnd) {
4891 continue;
4892 }
4893 postMouseButton(hwnd, mousebutton, keyupdown, mousepoint);
4894 }

Callers

nothing calls this directly

Calls 3

containsMethod · 0.80
isEmptyMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected