qt 3.0.3中的鼠标单击事件
鼠标按钮单击我正在尝试在特定坐标处创建自动鼠标单击事件 此源代码将鼠标指针移动到坐标区域,但它没有单击 请帮助我解决这个问题,或提出任何新的想法来自动鼠标点击事件 注意:我使用的是Qt3.0.3qt 3.0.3中的鼠标单击事件,qt,Qt,鼠标按钮单击我正在尝试在特定坐标处创建自动鼠标单击事件 此源代码将鼠标指针移动到坐标区域,但它没有单击 请帮助我解决这个问题,或提出任何新的想法来自动鼠标点击事件 注意:我使用的是Qt3.0.3 void mMouseClickFunction() { QWidget *d = QApplication::desktop()->screen(); int w=d->width(); // returns desktop width int h=d-&
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;
}
void mMouseClickFunction()
{
QWidget*d=QApplication::desktop()->screen();
int w=d->width();//返回桌面宽度
inth=d->height();
printf(“w=%d\nh=%d\n”,w,h);
int x,y;
printf(“输入点…\n”);
scanf(“%d%d”,&x,&y);
QApplication::desktop()->cursor().setPos(x,y);
点pt(x,y);
std::coutQApplication::sendEvent
向QApplication内部发送事件,而不是系统范围的事件。您可能需要特定于系统才能发送这样的事件。以下是windows的函数调用:
但是,即使使用这种调用,您也将受限于某些窗口,除非您具有真实的UIAccess,并且您的程序是位于硬盘驱动器右侧的签名应用程序
编辑:下面是一个页面,其中有一些在Linux中发送输入的示例:
希望能有所帮助。我在linux环境中需要同样的帮助,而不是windows。谢谢你的建议……请帮助我解决问题。我已经实现了与上述linux链接相同的功能,但问题是它支持X86 artitech,但不支持交叉编译。我需要同样的功能进行交叉编译。请为我提供建议plsso您的意思是让它在32位linux和64位linux上工作吗?使用Qt可以轻松地为不同的操作系统和不同的体系结构重新编译。您仍然需要编译它。至少在windows上,您可以在64位体系结构上运行win32应用程序。要分发到许多linux设置,您需要提供源代码,并让每个人自己编译它,或者您需要制作一个已为通用硬件设置编译的发行版。