While Loop Taking Alot of CPU Usage
- by CuriousUser
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:
http://www.rohitab.com/discuss/index.php?showtopic=9931
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 wanna know if there's anyway to decrease the CPU usage, without losing function.
P.S How would I make a key shortcut? Like press (Ctrl + E) to make the program exit?