I don't think so.
For example, on Windows I think your starting point should be WriteConsoleInput
Something like this:
Code:
#include <iostream>
#include <vector>
#include <cctype>
#include <windows.h>
void send_to_input_stream(const std::string& msg)
{
std::vector<INPUT_RECORD> events;
for (unsigned i = 0; i != msg.size(); ++i) {
//sloppily handle characters A-Za-z and space
//TODO: do lots of work to handle all characters
char c = std::toupper(msg[i]);
if ((c >= 'A' && c <= 'Z') || c == ' ') {
INPUT_RECORD rec_template;
//fill in a key-down event
rec_template.EventType = KEY_EVENT;
rec_template.Event.KeyEvent.bKeyDown = TRUE;
rec_template.Event.KeyEvent.wRepeatCount = 1;
rec_template.Event.KeyEvent.wVirtualKeyCode = c;
rec_template.Event.KeyEvent.wVirtualScanCode = MapVirtualKey(c, 0);
rec_template.Event.KeyEvent.uChar.AsciiChar = msg[i];
rec_template.Event.KeyEvent.dwControlKeyState = std::isupper(msg[i]) ? SHIFT_PRESSED : 0;
events.push_back(rec_template);
//change to add corresponding key-up event
rec_template.Event.KeyEvent.bKeyDown = FALSE;
rec_template.Event.KeyEvent.dwControlKeyState = 0;
events.push_back(rec_template);
}
}
DWORD written_count;
WriteConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &events[0], events.size(), &written_count);
}
int main()
{
std::cout << "Please change this text: ";
send_to_input_stream("This is to be in the prompt the users edits");
std::string input;
std::getline(std::cin, input);
std::cout << input;
}