Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:25:28+00:00 2026-05-27T01:25:28+00:00

My program opens a series of forms all over the screen, am I able

  • 0

My program opens a series of forms all over the screen, am I able to code in an escape method, so on typing of the word “test” the program will close?

I was looking at the msdn keypress and how they use a switch, would I use something similar to check for the pressed key and if the correct key is pressed, a counter will increment of the correct key presses until, for “test”, 4 will be reached, and if the pressed key is incorrect reset the counter and start over until the right order of keys are entered.

I hope that makes sense 😛

public partial class TrollFrm : Form
{
    int number = 1; //change to 2 and have the first instance of troll count = number - 1

    System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();

    public TrollFrm()
    {
        InitializeComponent();

        this.Text = "Trololol - Troll Count: " + number;

        startTimer();

    }

    private void TrollFrm_Load(object sender, EventArgs e)
    {
       //this.Enabled = false;
    }

    private void TrollFrm_FormClosing(object sender, FormClosingEventArgs e)
    {
        e.Cancel = true;
    }

    public void startTimer()
    {
        myTimer.Tick += new EventHandler(createForm);

        //myTimer.Interval = 500;

        myTimer.Start();

    }

    public void createForm(Object myObject, EventArgs myEventArgs)
    {
        Form frm = new TrollChildFrm();

        Random randomX = new Random();

        Random randomY = new Random();

        frm.Text = "Trololol - Troll Count: " + number;

        int xValue;

        int yValue;

        number++;

        if (number % 2 == 0)    //number is even.
        {
            xValue = (Convert.ToInt32(randomX.Next(1, 1920))) + 200;

            yValue = (Convert.ToInt32(randomY.Next(1, 1080))) - 200;
        }

        else    //number is not even.
        {
            xValue = (Convert.ToInt32(randomX.Next(1, 1920))) - 200;

            yValue = (Convert.ToInt32(randomY.Next(1, 1080))) + 200;
        }

        frm.Show();

        frm.Location = new Point(xValue, yValue);

        if (number == 20)
        {
            myTimer.Stop();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:25:28+00:00Added an answer on May 27, 2026 at 1:25 am

    It is an implementation you could use for scenario you described (not tested though):

    int exitKeysCount = 0;
    private void TrollFrm_KeyDown(object sender, KeyEventArgs e)
    {
        if (exitKeysCount == 0 && e.KeyCode == Keys.T)
            exitKeysCount = 1;
        else if (exitKeysCount == 1 && e.KeyCode == Keys.E)
            exitKeysCount = 2;
        else if (exitKeysCount == 2 && e.KeyCode == Keys.S)
            exitKeysCount = 3;
        else if (exitKeysCount == 3 && e.KeyCode == Keys.T)
            this.Close();
        else exitKeysCount = 0;
    }
    

    I assumed TrollFrm is your parent form, if they are all invoked somewhere else replace this.Close() with some function in main program function, also TrollFrm needs focus during key presses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a code that when a user opens my program, a code start
My program opens a socket on port 80, but if I don't run it
I made a program that opens an application, sleeps the thread for 500ms then
I have a python program that opens several urls in seperate tabs in a
I have a Java program that opens a file using the RandomAccessFile class. I'd
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I want to create a program which opens my file onClick by providing its
I am coding a program where a form opens for a certain period of
I have a program that when it starts, opens a winform (it is the
I have a program that opens a large binary file, appends a small amount

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.