Thread: how to handle keyboard and mouse events for all windows

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    15

    how to handle keyboard and mouse events for all windows

    Hi all,

    how to handle (or just get notified about) a keyboard or mouse event happened for any open window OR desktop itself.

    what I want to do is just run in a loop sleeping 1 second before each iteration, checking if any mouse or keyboard event happened in any window, and if no such event happens in say 5 seconds then do something.

    in short i want to detect if system was idle for a period of time. i can use c/c++. win32api OR MFC.

    hope, someone knows something...

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Read "Windows Programming 5th Edition" by Charles Petzold.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    A system wide keyboard hook example. All you need to add is a MOUSEHOOKSTRUCT to capture system wide mouse movement. Then you can just determine the idle time between mouse and/or keyboard events.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    15
    thanks to all! problem is fixed now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Windows) Send keyboard and mouse to another program?
    By Chrisname in forum Windows Programming
    Replies: 4
    Last Post: 06-13-2009, 06:13 PM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. simulate keyboard events on windows xp
    By xximranxx in forum Windows Programming
    Replies: 4
    Last Post: 04-26-2007, 05:43 PM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 03:34 PM