summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-23 22:33:00 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-23 22:33:00 +0300
commit7863473dc201f4a497669cbf69875eb6e9389273 (patch)
treeb80920475c72e64951798541274ca13b084c6ae6
parent50b6e25bb094fc1942028b711a9d9cc3ac491831 (diff)
downloadplus-7863473dc201f4a497669cbf69875eb6e9389273.tar.gz
plus-7863473dc201f4a497669cbf69875eb6e9389273.tar.bz2
plus-7863473dc201f4a497669cbf69875eb6e9389273.tar.xz
plus-7863473dc201f4a497669cbf69875eb6e9389273.zip
Add chat command for simulate mouse click by any position and button.
-rw-r--r--src/actions/chat.cpp27
-rw-r--r--src/actions/chat.h1
-rw-r--r--src/dyetool/actions/chat.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h6
5 files changed, 36 insertions, 0 deletions
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<MouseButtonT>(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
diff --git a/src/dyetool/actions/chat.cpp b/src/dyetool/actions/chat.cpp
index 3d5dcf5c7..bf57c1c49 100644
--- a/src/dyetool/actions/chat.cpp
+++ b/src/dyetool/actions/chat.cpp
@@ -63,5 +63,6 @@ impHandlerVoid(chatClipboard)
impHandlerVoid(guildNotice)
impHandlerVoid(translate)
impHandlerVoid(sendGuiKey)
+impHandlerVoid(sendMouseKey)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 2be35e654..9b1d2e99a 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -693,6 +693,7 @@ enumStart(InputAction)
MOVE_PRIORITY_ATTACK_UP,
MOVE_PRIORITY_ATTACK_DOWN,
SHOW_ITEMS,
+ COMMAND_SEND_MOUSE_KEY,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 908a0d4b5..bc18cd7a4 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5648,6 +5648,12 @@ static const InputActionData inputActionData
"showitems|items|itemsshow",
UseArgs_true,
Protected_true},
+ {"keyCommandSendMouseKey",
+ defaultAction(&Actions::sendMouseKey),
+ InputCondition::ENABLED,
+ "mousekey|sendmousekey",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction