MOuse Click event in Window/desktop by susing QT
-
Mouse button clicki am trying to create an automatic mouse click event at a particular co ordinate.
This source code moves the mouse pointer to the co ordinate region but it is not clicking.
please help me to solve this problem or suggest any new idea to automate mouse click event.
I am seek of this.....???
Note: i am using QT 3.0.3
void mMouseClickFunction()
{QWidget *d = QApplication::desktop()->screen();
int w=d->width(); // returns desktop width
int h=d->height();
printf("w=%d\nh=%d\n",w,h);
int x,y;
printf("Enter the points...\n");
scanf("%d%d",&x,&y);
QApplication::desktop()->cursor().setPos(x,y);
QPoint pt(x,y);
std::cout << pt.x() << " " << pt.y() << std::endl;
QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, pt,Qt::LeftButton, 0);
QApplication::sendEvent(d, e);
std::cout << "in contentsMousePressEvent" \
<< e->x() << " " << e->y() << std::endl;
QMouseEvent *p = new QMouseEvent(QEvent::MouseButtonRelease, pt,Qt::LeftButton, 0);
QApplication::sendEvent(d, p);
std::cout << "in contentsMouseReleaseEvent" \
<< p->x() << " " << p->y() << std::endl;}
-
What does QMouseEvent::globalPos() gives back?
Check the doc: http://doc.qt.digia.com/3.3/qmouseevent.html#globalPos
Maybe this will help you.
-
Your goal is to write a click simulation software.
A normal click under linux/X11 would be Mouse->XInput->QEvent
What you would like to do is QEvent->XInputHere is a possible google solution:
http://stackoverflow.com/questions/10081588/qt-monitor-global-cursor-click-event-with-x11