Results 1 to 4 of 4

Thread: Mouseclick outside from widget

  1. #1
    Join Date
    Nov 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Mouseclick outside from widget

    Hello,

    i want set and click the cursor outside from my Application (e.k. a game in windowsmode or a word dokument).

    I have tested
    Qt Code:
    1. QCursor::setPos(10,10);
    To copy to clipboard, switch view to plain text mode 
    to set my Mouseposition. Its work, the mousposition are outside on my widget and application(my application is only 1 px big).
    but the click doesnt work

    I have use/testing
    Qt Code:
    1. #include <Windows.h>
    2. ...
    3. mouse_event(MOUSEEVENTF_LEFTDOWN,0, 0, 0,0);
    4. mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0,0);
    To copy to clipboard, switch view to plain text mode 
    or

    Qt Code:
    1. CONFIG += qtestlib
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <QtTest/QTest>
    2. ...
    3. QTestEventList *eventList=new QTestEventList();
    4. eventList->addDelay(2000);
    5. eventList->addMouseMove(QPoint(15,35));
    6. eventList->addMouseClick(Qt::LeftButton,Qt::NoModifier,QPoint(15,35));
    7. eventList->simulate(this);
    To copy to clipboard, switch view to plain text mode 

    but nothing work

    Idont know what i can do.... can someone help me please ?

  2. #2
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouseclick outside from widget

    AFAIK there's no way Qt simulate window manager events (like mouse click) outside your own app.
    You need to ask window manager to do it for you (calling SendInput on Windows or XSendEvent on X11.

  3. #3
    Join Date
    Nov 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouseclick outside from widget

    I have think that
    Qt Code:
    1. mouse_event(MOUSEEVENTF_LEFTDOWN,0, 0, 0,0);
    2. mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0,0);
    To copy to clipboard, switch view to plain text mode 
    is to say the Windows API what they must do maybe outside my application

  4. #4
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouseclick outside from widget

    Yeah, I missed it.

    So, maybe you should try adding MOUSEEVENTF_ABSOLUTE flag?

Similar Threads

  1. Selecting next line with mouseclick
    By Jake123 in forum Newbie
    Replies: 1
    Last Post: 4th February 2013, 06:21
  2. Replies: 3
    Last Post: 13th October 2011, 11:53
  3. Getting sender for mouseclick with QwtPlot
    By lxman in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2011, 01:43
  4. how to get MouseClick Event in this case
    By yxmaomao in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2008, 03:03
  5. select QGraphicsItems by mouseclick
    By Shawn in forum Qt Programming
    Replies: 20
    Last Post: 31st July 2007, 13:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.