Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Control mouse pointer with Qt even outside the Qt application.
Forum Updated to NodeBB v4.3 + New Features

Control mouse pointer with Qt even outside the Qt application.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kajjah
    wrote on last edited by
    #1

    Hi all, first let me explain the plot, i have been building an application that can emulate the functions of a mouse using hand gestures. I did the gesture recognition part using OpenCV. I am trying to make a GUI interface using Qt.

    As an initial step, I am currently trying to control the mouse using the keyboard. I assigned the keys A W D S to move the mouse in all the directions using
    void QCursor::setPos ( int x, int y ). Its working fine.

    Then i used the windows API function:
    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 1, 1, 0, 0);
    to simulate the mouse click.

    Its is also working but when i click anywhere outside the Qt application the focus shifts and i loose control of the mouse through the keyboard. Is there any remedy for this?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TioRoy
      wrote on last edited by
      #2

      If you already use Win32 Api, you can force the focus calling SetFocus.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kajjah
        wrote on last edited by
        #3

        i tried to set the focus using

        SetFocus(GetActiveWindow());

        but there was no success. The control jumps to the next window onto which i click using my 'O' key(i have assigned O Key to perform single click). Any remedy for this?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved