GetAsyncKeyState(int vKey) - Problem

This is a discussion on GetAsyncKeyState(int vKey) - Problem within the C++ Programming forums, part of the General Programming Boards category; Anyone know of a way to empty the buffer after using the GetAsyncKeyState() function? If I can't empty it after ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    80

    GetAsyncKeyState(int vKey) - Problem

    Anyone know of a way to empty the buffer after using the GetAsyncKeyState() function? If I can't empty
    it after each function call the program will behave badly.... I am looping a few functions, including that one. It seems to register more than one keypress sometimes and I don't know what to do about it.
    I would appreciate any help greatly.

  2. #2
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154
    Have you tried setting the parameter to zero? That might work, but I doubt it, it's worth a go anyway. It obviously isn't going to work if there is a key with the "ID number" of zero.

  3. #3
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    I am not sure about this, but I don't think the problem is with GetAsyncKeyState but rather your code. Notice the async in the word "GetAsyncKeyState".

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    80
    Thx for your replies. I found a solution... Yes MadCow you were right.. it was my code..
    when I did it like this:

    Code:
    /...................../
    if (GetAsyncKeyState(0x25) == -32767){
        insert code here
    }
    /...................../
    when I checked the return value to see if the button had been pressed it worked fine..
    before this it must have checked both button presses and if any button was held down.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

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