Results 1 to 7 of 7

Thread: How to know if somebody is using the PC?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    165
    Thanked 2 Times in 2 Posts

    Default How to know if somebody is using the PC?

    Hello!

    I want to create a function in my software that, before doing something, verifies if there is somebody using the PC. I imagine that the best way to do that is implement an algorithm that verifies if the keyboard or the mouse has been used in the past X seconds (I guess 10 seconds is already enough). If not, than it moves on, but if yes, than it waits. [as an analogy, the idea is to implement the same thing Windows has to verifiy if it should start the screen protection or diactivate graphics).

    I guess:
    What I would have to do is to connect the MouseMove Event and some sort of Keyboard Press Event to a variable that stores the current time when the event happens. When the time comes, this variable will be read and if there is X or more time elapsed since the last mouse or keyboard was touched, the software goes on.

    The problem is that this MouseMove catcher and keyboard press catcher must be on even when the software is not focused (i.e. when it's not been selected, viewed, used, etc., i.e. runnning in background). Now how can I do that?


    So, summarizing:
    * How to make mouse move events and keyboard press events be captured even when the software runs in background?
    * Which are the methods that should be used to capture the Keyboard inputs?


    Thanks,


    Momergil

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: How to know if somebody is using the PC?

    Did you search the forum before asking this question? It has been asked and answered a number of times already.
    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
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: How to know if somebody is using the PC?

    This has nothing to do with Qt.
    Here is a sample project which is doing hooking.
    http://www.codeproject.com/Articles/...ard-Hooks-in-C

    And of course this is highly NOT portable!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Tags for this Thread

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.