Preload settings from text file?
Author |
Message |
0x8000
|
Posted: Sun Jun 18, 2006 8:06 pm Post subject: Preload settings from text file? |
|
|
Okay I have this program (code below), and basically it just makes the cursor move down when you press mouse1, you can adjust the speed with [ and ], as well as + and -, now I want to be able to preload settings from a text file, so for example in the text file have the basic setting like "movedown 2.3", how would I go abouts doing that?
code: | #include <windows.h>
#include <iostream.h>
#define VK_OEM_PLUS 0xBB
#define VK_OEM_MINUS 0xBD
#define VK_OEM_4 0xDB
#define VK_OEM_6 0xDD
//defines keys PLUS, MINUS, ], and [
using namespace std;
static int time_effector = 1;
static int pixel_effector = 0;
//declares integers that makes how much moving-downwards to produce
int main()
{
std::cout << "ANTIRECOIL by LIX";
while(1) //run forever
{
Sleep(time_effector); //run forever
if(GetAsyncKeyState(VK_LBUTTON)&0x8000) // if MOUSE1 is being pressed
{
POINT pos; // declare POINT position
GetCursorPos(&pos); // get cursor position
SetCursorPos(pos.x, pos.y-pixel_effector); //set anti-recoiled position by looking @ pixel_effector
}
if(GetAsyncKeyState(VK_OEM_PLUS)&1){time_effector++;} //contains time in ms to wait between loops
if(GetAsyncKeyState(VK_OEM_MINUS)&1){time_effector--;} //-- same as above
if(GetAsyncKeyState(VK_OEM_4)&1){pixel_effector++;} // if PLUS is pressed, pixel_effector plus 1
if(GetAsyncKeyState(VK_OEM_6)&1){pixel_effector--;} // if minus is pressed, pixel_effector minus 1
if(GetAsyncKeyState(VK_DELETE)&1){ExitProcess(0);} //as its a forever loop, something must enable program to exit
}
} |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Martin
|
Posted: Sun Jun 18, 2006 8:36 pm Post subject: (No subject) |
|
|
The header file that you're looking for is fstream. Here's a tutorial - http://www.functionx.com/cpp/articles/filestreaming.htm
I wouldn't recommend getting into Windows API calls just yet. That stuff gets very complicated very quickly.
And use iostream instead of iostream.h!
iostream.h is the header for pre-standard input/output streams written 15+ years ago by AT&T. iostream is the standard for io streams, as specified by the C++ standard in 1998. |
|
|
|
|
|
|
|