MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / input_text

Method input_text

source/MaaWin32ControlUnit/Input/MessageInput.cpp:1080–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1078}
1079
1080bool MessageInput::input_text(const std::string& text)
1081{
1082 LogInfo << VAR(config_.mode) << VAR(config_.with_cursor_pos) << VAR(config_.with_window_pos) << VAR(text);
1083
1084 if (!hwnd_) {
1085 LogError << VAR(config_.mode) << VAR(config_.with_cursor_pos) << VAR(config_.with_window_pos) << "hwnd_ is nullptr";
1086 return false;
1087 }
1088
1089 HWND target = send_activate();
1090
1091 bool success = true;
1092
1093 for (const auto ch : to_u16(text)) {
1094 success &= send_or_post_w(target, WM_CHAR, static_cast<WPARAM>(ch), 0);
1095 std::this_thread::sleep_for(std::chrono::milliseconds(50));
1096 }
1097 return success;
1098}
1099
1100bool MessageInput::key_down(int key)
1101{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected