For simulating key presses you can use the QKeyEvent
class which describes a key event and post that using QCoreApplication::postEvent
.
QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter);
qApp->postEvent (receiver, event)
You can set the global position of the mouse by
QCursor::setPos(100,100);
Simulating the mouse events are like:
QMouseEvent * event = new QMouseEvent ((QEvent::MouseButtonPress), QPoint(500,500),
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier );
qApp->postEvent((QObject*)this,(QEvent *)event);