[New]C++ Code

10/06/2012 10:07 LogLife#1
Please some one advice to me if i need the code from c++ for check keyboard button presses, For the concept when player press "Enter" key three time per five sec then exit process.
Please make example code for me thank you for advice.
10/06/2012 10:26 BioNicX#2
its in the exe i believe. you need to edit the client side exe.

PS: why do you put "[NEW]" ? , the forum lets us know if the thread is new or not lol.
10/06/2012 13:17 WarmongerR4#3
You should just use a low level keyboard hook. I'm not going to post any code for sake of nubcakes making keyloggers from it. Look more into SetWindowsHookEx() using WH_KEYBOARD_LL.
10/07/2012 05:59 freeskier4lif3#4
Code:
// How long should we allow for the 3 presses?
double timeSpan = 5.0;  // let's go with 5 seconds for this example as you asked

int counter = 0;  // used to count number of times Enter is pressed

// VARIABLES FOR TIMING
LARGE_INTEGER frequency;
LARGE_INTEGER startTime, currentTime;
double elapsedTime = 0;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&startTime);


// CHECK for KEY PRESS
if(GetAsyncKeyState(VK_RETURN))
{
  // Calculate the time from last press
  QueryPerformanceCounter(&currentTime);
  elapsedTime = (currentTime.QuadPart - startTime.QuadPart) * 1000.0 / frequency.QuadPart;

  // If we are within the set time
  if(elapsedTime < timeSpan)
  {
     counter++;
  }
  else
  {
    // Set a new start time
    QueryPerformanceCounter(&startTime);
    counter = 1;
  }

  //Are we at 3 or more clicks of enter?
  if(counter >= 3)
  {
     exit(-1);  // exit the game
  }
}
10/07/2012 06:07 LogLife#5
Code:
Compiling...
Entercount.cpp
C:\Users\Administrator\Desktop\Enter\Entercount.cpp(197) : error C2065: 'VK_ENTER' : undeclared identifier
C:\Users\Administrator\Desktop\Enter\Entercount.cpp(211) : error C2065: '$startTime' : undeclared identifier
Error executing cl.exe.

Entercount.dll - 2 error(s), 0 warning(s)
10/07/2012 06:13 freeskier4lif3#6
couple typos... you should have been able to figure it out was just an example. edited it though.
10/07/2012 08:51 kokamentos#7
Quote:
Originally Posted by LogLife View Post
Code:
Compiling...
Entercount.cpp
C:\Users\Administrator\Desktop\Enter\Entercount.cpp(197) : error C2065: 'VK_ENTER' : undeclared identifier
C:\Users\Administrator\Desktop\Enter\Entercount.cpp(211) : error C2065: '$startTime' : undeclared identifier
Error executing cl.exe.

Entercount.dll - 2 error(s), 0 warning(s)
You need WinUser.h

#define VK_RETURN 0x0D