how to handle keyboard and mouse events for all windows

This is a discussion on how to handle keyboard and mouse events for all windows within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, how to handle (or just get notified about) a keyboard or mouse event happened for any open window ...

  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
    Katy, Texas
    Posts
    2,309
    Read "Windows Programming 5th Edition" by Charles Petzold.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    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, 07: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, 06: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, 04:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21