GetKeyState的疑惑

#include "stdafx.h"
#include <Windows.h>
int main()
{
    int i = 0;
    while(1)
    {
        if(GetKeyState('A') < 0)
        {
            //VK_CONTROL
            //printf("Ctrl down: %d!\n", ++i);
            printf("A down: %d!\n", ++i);
        }
        //Sleep(1000);
    }
    return 0;
}

用GetKeyState来截获密码等好像不太实际,如果在死循环中Sleep就可能漏掉信息,如果不Sleep你会发现按一次键能得到N次这个键的信息。

疑惑是GetKeyState好像取不到WH_KEYBOARD_LL Hook后的键信息?



Comments are closed.