Click here to Skip to main content
16,004,974 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'd like to make a c# console application menu..
I want a green True and a red False..
For example, If I click f1 the text changes to "True" (green)
And if I press f1 AGAIN it changes to "Flase" (red)
C#
Console.Write("Bhop: ");
                   Console.Write("True");

I'd like to to change "True" to false when I click "F1" on my keyboard..
( I know how to use color like
<pre lang="c#">Console.ForegroundColor = ConsoleColor.White;
But I want it to change when I click "F1", also I want the text to change from True to False and back when I click f1..)


Thanks,

Mitch

What I have tried:

I tried it with if else etc etc but I'm not that good with c#
Please help me! I'd love to make my menu work like that!
Posted
Updated 26-Aug-18 15:00pm
v2
Comments
[no name] 26-Aug-18 13:59pm    
Member 13961392 26-Aug-18 14:23pm    
I know how to use color in c#, But I want it to change when I click on "F1", also I want the text to change,

Thanks for helping!
[no name] 26-Aug-18 14:42pm    
Sorry, that was not clear before you extended your question. So how about a variable bool state which you toggle on every F1 like state= !state;
Richard Deeming 28-Aug-18 14:40pm    
Perhaps you're looking for something like this:
Gui.cs - Terminal UI toolkit for .NET[^]

1 solution

As much as I don't want to help someone make a bhop script...

C#
ConsoleKeyInfo keyinfo;
var bhopscriptstatus = false;
Console.Write("Welcome to my script, press F1 to toggle bhop!" + Environment.NewLine);
do
{
    keyinfo = Console.ReadKey();
    if (keyinfo.Key == ConsoleKey.F1)
    {
        bhopscriptstatus = !bhopscriptstatus;
        if (bhopscriptstatus)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("Cheating: Active" + Environment.NewLine);
        }
        else
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Cheating: Disabled" + Environment.NewLine);
        }
    }

}
while (true);
 
Share this answer
 
v4
Comments
Member 13961392 27-Aug-18 9:26am    
Hello,

I truely understand why you don't want to help, Thanks that you did anyways..
This helped me alot, I use this progject (Cheats) To improve my knowledge of c#..
Thanks for helping!

Mitch
Member 13961392 27-Aug-18 9:32am    
UPDATE:

This doesn't work in my code.. "bhopscriptstatus" is an error..
I'm very new to this kind of coding, could you maybe explain/help me how to fix the error?

Thank you so much!

Mitch
TommoDotCommo 27-Aug-18 21:05pm    
That's my mistake, you'll need to declare bhopscriptstatus first, I've changed my answer.
Member 13961392 30-Aug-18 12:50pm    
Thank you so much!
Member 13961392 30-Aug-18 12:54pm    
It still doesnt update when I click F1..

Thanks,
Mitch

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900