Thread: using GetKeyAsyncState

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    using GetKeyAsyncState

    I'm trying to learn how GetAsyncKeyState works. With this code when escape is pressed it's suppose to break out of the loop, but it doesn't. Why not? In a GUI App would I put this in my message loop?
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main(void)
    {
       while(1)
       {
          if(GetAsyncKeyState(VK_ESCAPE))
          {
             break;
          }
       }
       return 0;
    }
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    GetAsyncKeyState will not work in a DOS application. You need to have a message loop.

Popular pages Recent additions subscribe to a feed