using two GetAsyncKeyState a while statement with an or condition

This is a discussion on using two GetAsyncKeyState a while statement with an or condition within the Windows Programming forums, part of the Platform Specific Boards category; i have tried to make a program terminal when either of the two control keys are hit however the program ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    2

    using two GetAsyncKeyState a while statement with an or condition

    i have tried to make a program terminal when either of the two control keys are hit however the program only seem to terminal when which ever ctrl key is in front of the ||

    here is the while statement

    Code:
    
        } while (!GetAsyncKeyState(VK_LCONTROL) || (!GetAsyncKeyState(VK_RCONTROL)));
    is it possible to get this work or is it impossible with the GetAsyncKeyState function
    Last edited by Rob Fisher; 01-11-2013 at 03:26 AM. Reason: missed a bracket

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    GetAsyncKeyState function (Windows)
    If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.
    If the first call returns false, you burned your chance at detecting anything on the second call (which follows almost immediately)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    2
    so what do you suggest I do to make this work, so it terminates the while loop on either control key?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Well all I did was read the manual page for the function you called, and copy/pasted it here.
    You ought to at least to be able to do that much for yourself (we're not here to read the manual for you).

    The next thing to do is look to the left of the manual page you're now looking at, and see the API reference hierarchy.

    So start with all the functions in Keyboard Input Functions to see if there is anything better you could use.

    If that doesn't work, then read through the overview in Keyboard Input Reference to make sure you understand the general concept.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can I call a function inside condition of if statement?
    By Meerul264 in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2012, 10:06 PM
  2. if-else statement condition
    By YouMe in forum C Programming
    Replies: 16
    Last Post: 07-04-2012, 09:48 AM
  3. GetAsyncKeyState for Mac?
    By Treeham in forum C++ Programming
    Replies: 1
    Last Post: 08-29-2010, 08:38 PM
  4. GetAsyncKeyState.
    By kevinawad in forum Windows Programming
    Replies: 9
    Last Post: 11-09-2008, 04:02 PM
  5. GetAsyncKeyState
    By bobbelPoP in forum Windows Programming
    Replies: 3
    Last Post: 07-18-2008, 04:44 PM

Tags for this Thread


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