8 Replies - 557 Views - Last Post: 02 August 2009 - 09:20 PM Rate Topic: -----

#1 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

How do i make part of this constantly check while enabled

Posted 01 August 2009 - 12:46 PM

Ok i have my code here. I need this part

if (GetAsyncKeyState(VK_F11))
					{
					if(!keyWasPressed)
						{
						keyWasPressed = true;
							cout << "\n Prevention Enabled" << endl;
							if (getCurrentD() > 0)
							{
				if (getCurrentD() <= D_MinValue)
								Stop();
							}
						Sleep(400);
						}
					else
						{
						keyWasPressed = false;
							cout << "\n Prevention Disabled" << endl;

							Sleep(400);
						}
					}



So what i need is how do i make it constantly check this

 if (getCurrentD() > 0)
							{
				if (getCurrentD() <= D_MinValue)
								Stop();
							}
						Sleep(400);
						}



that way when D gets below the min value it uses the Stop();

Is This A Good Question/Topic? 0
  • +

Replies To: How do i make part of this constantly check while enabled

#2 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: How do i make part of this constantly check while enabled

Posted 01 August 2009 - 01:05 PM

You can use a while loop. This will keep going until the user chooses to quit. Just don't forget to put your stop condition within the while loop. :)
char quit = 'c';
while(quit != 'Q')
 {
	 //do stuff
	
	 //see if user wants to quit
	 cout<<"Quit or Continue?\n";
	 cin>>quit;
 }

This post has been edited by OliveOyl3471: 01 August 2009 - 01:06 PM

Was This Post Helpful? 0
  • +
  • -

#3 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

Re: How do i make part of this constantly check while enabled

Posted 01 August 2009 - 01:40 PM

View PostOliveOyl3471, on 1 Aug, 2009 - 12:05 PM, said:

You can use a while loop. This will keep going until the user chooses to quit. Just don't forget to put your stop condition within the while loop. :)
char quit = 'c';
while(quit != 'Q')
 {
	 //do stuff
	
	 //see if user wants to quit
	 cout<<"Quit or Continue?\n";
	 cin>>quit;
 }

I cant use this method. I need it to have it running in back ground like user presses The button and it prints out
Prevention enabled
and then repeasts the code until user press key again
Was This Post Helpful? 0
  • +
  • -

#4 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: How do i make part of this constantly check while enabled

Posted 01 August 2009 - 03:19 PM

View Postgibson_junk, on 1 Aug, 2009 - 03:40 PM, said:

I cant use this method. I need it to have it running in back ground like user presses The button and it prints out
Prevention enabled
and then repeasts the code until user press key again


Why not? A while loop will repeat the code until a certain condition is met. Just put the condition in the () part
while(!conditionMet)
{
//repeat code
//check if condition is met
}
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5234
  • View blog
  • Posts: 27,024
  • Joined: 10-May 07

Re: How do i make part of this constantly check while enabled

Posted 01 August 2009 - 08:42 PM

Without knowing more about what you are trying to do, a loop really is the best way to continue processing until a condition is met.
Was This Post Helpful? 0
  • +
  • -

#6 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

Re: How do i make part of this constantly check while enabled

Posted 02 August 2009 - 12:33 AM

Maybe this will help. Once the user enables it i want it to run but i only want it to say enabled 1 time and then keep running in the background until the user disables it by hitting f11 again

can you give me the code to do this. I am confused by what you are saying
Was This Post Helpful? 0
  • +
  • -

#7 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: How do i make part of this constantly check while enabled

Posted 02 August 2009 - 12:55 AM

okay, once the user enables it, add a while loop:

//code to enable it goes here

while(!userPressedf11) //however you word your condition, it won't be like this though
{
//repeat code
//check if condition is met (when they press f11) and if it is met, then the loop ends, thus ending the repeating code
}

You can write the code yourself. I just gave you pseudocode, to give an idea of the way to use this while loop.
Was This Post Helpful? 0
  • +
  • -

#8 gibson_junk  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 89
  • Joined: 24-July 09

Re: How do i make part of this constantly check while enabled

Posted 02 August 2009 - 01:41 AM

View PostOliveOyl3471, on 1 Aug, 2009 - 11:55 PM, said:

okay, once the user enables it, add a while loop:

//code to enable it goes here

while(!userPressedf11) //however you word your condition, it won't be like this though
{
//repeat code
//check if condition is met (when they press f11) and if it is met, then the loop ends, thus ending the repeating code
}

You can write the code yourself. I just gave you pseudocode, to give an idea of the way to use this while loop.


Sorry but i try this
. Doesn't work. SOrry for not understanding you 100% but for me what you say i don't understand.
if (GetAsyncKeyState(VK_F11))
					{
					if(!keyWasPressed)
						{
						keyWasPressed = true;
							 while(keyWasPressed = true)
{
									 cout << "\n Prevention Enabled" << endl;
									 if (getCurrentD() > 0)
							{
									if (getCurrentD() <= D_MinValue)
										Stop();
}
							}
						Sleep(400);
						}
					else
						{
						keyWasPressed = false;
							cout << "\n Prevention Disabled" << endl;

							Sleep(400);
						}
					}


Was This Post Helpful? 0
  • +
  • -

#9 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: How do i make part of this constantly check while enabled

Posted 02 August 2009 - 09:20 PM

Sorry I couldn't help you. Maybe someone else can. :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1