Results 1 to 4 of 4

Thread: Automate Mousse click event

  1. #1
    Join Date
    Oct 2012
    Posts
    2
    Qt products
    Qt3
    Platforms
    Windows

    Lightbulb Automate Mousse click event

    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.

    Note: i am using QT 3.0.3



    i am seek of thie please help me



    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;



    }

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Automate Mousse click event

    If you are trying to generate a click for the desktop or window that is outside your application then it won't work. Qt's events are not translated into system events. Using postEvent()/sendEvent() you can only inject events for your own application.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Automate Mousse click event

    canu pls provide me the suggestion to solve the problem

    i am seek of this
    Last edited by kuppan-j; 2nd April 2013 at 08:09.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Automate Mousse click event

    Use native system API. This is out of scope of this forum.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. pushButton click event
    By aj2903 in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 12:19
  2. click Event on Title Bar
    By anupamgee in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2009, 18:12
  3. On click event for a QPixmap
    By rishid in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2008, 17:12
  4. PostgreSQL and QT4 automate id problem!
    By nnidza in forum Qt Programming
    Replies: 9
    Last Post: 31st December 2006, 00:16
  5. mouse click event
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2006, 10:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.