From 7863473dc201f4a497669cbf69875eb6e9389273 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 May 2017 22:33:00 +0300 Subject: Add chat command for simulate mouse click by any position and button. --- src/actions/chat.cpp | 27 +++++++++++++++++++++++++++ src/actions/chat.h | 1 + 2 files changed, 28 insertions(+) (limited to 'src/actions') diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index 9591ea00f..d8743e06a 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -753,4 +753,31 @@ impHandler(sendGuiKey) return true; } +impHandler(sendMouseKey) +{ + if (!guiInput) + return false; + const std::string args = event.args; + if (args.empty()) + return false; + StringVect pars; + if (!splitParameters(pars, args, " ,", '\"')) + return false; + const int sz = CAST_S32(pars.size()); + if (sz != 3) + return false; + + const int x = atoi(pars[0].c_str()); + const int y = atoi(pars[1].c_str()); + const int key1 = CAST_S32(MouseButton::LEFT); + const int key2 = CAST_S32(MouseButton::MIDDLE); + const int key = atoi(pars[2].c_str()); + if (key < key1 || key > key2) + return false; + guiInput->simulateMouseClick(x, + y, + static_cast(key)); + return true; +} + } // namespace Actions diff --git a/src/actions/chat.h b/src/actions/chat.h index 3815e53e7..5d4f1c02d 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -63,6 +63,7 @@ namespace Actions decHandler(guildNotice); decHandler(translate); decHandler(sendGuiKey); + decHandler(sendMouseKey); } // namespace Actions #undef decHandler -- cgit v1.2.3-60-g2f50