Results 1 to 2 of 2

Thread: Grab keyboard events in Windows

  1. #1
    Join Date
    Oct 2006
    Location
    Germany
    Posts
    84
    Thanks
    5
    Thanked 5 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Grab keyboard events in Windows

    Hello,
    I'm trying to write a really small program for myself. Whenever I use my Vol+ and Vol- keys on my keyboard I want to make a small OSD which shows the current volume.
    Well somehow I need to "grab" key events in Windows but I have no clue how to start.
    Qt only seems to support keyboard events within its own application but of course that's not going to work for me since the application will be hidden (and therefore not focused) and keyboard events won't work.
    I know this is possible, e.g. Trillian has a shortcut for "Display Contact List" and whenever the user presses that shortcut, the contact list opens.
    I guess I have to use native functionality for that but have no clue where to look. Can maybe someone point me to the right direction?
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Grab keyboard events in Windows

    I have done this before, but I currently don't have access to the code anymore.

    AFAIK, there are 2 possibilities:
    1. use GetAsyncKeyState in a loop
    2. install a global keyboard hook with SetWindowsHookEx

    Your profile says you're german so this will help you:
    http://dotnet.mvps.org/vb/articles/keyboardhook/

  3. The following user says thank you to kiker99 for this useful post:

    durbrak (5th February 2007)

Similar Threads

  1. handling keyboard events from a console app
    By g.cavallin in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2006, 23:31
  2. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 02:00
  3. Windows OLE drag & drop
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 12th September 2006, 10:47
  4. Replies: 2
    Last Post: 24th July 2006, 19:36
  5. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 23:33

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.