I am creating a keystroke logger for my personal interest, as well wanting to know how to capture and use them as functions (like key shortcuts).
I got the code to learn how keylogger and GetAsyncKeyState() work here.
I got it to run under Code::Blocks, but the weirdest things is that when I check my task manager, my CPU Usage rises to 100%. When I close the program, it goes back down, and goes back up to 100% when I turn it back on.
I presume it's because of the infinite while loop constantly checking for inputs, but I want to know if there's any way to decrease the CPU usage without losing function.
P.S How would I make a key shortcut? For example, pressing Ctrl+E to make the program exit.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…