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 380351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:58:51+00:00 2026-05-12T14:58:51+00:00

Hey guys im trying to get a simple button masher up, What i want

  • 0

Hey guys im trying to get a simple button masher up, What i want timer1 to do is mash keys in richtextbox1 for 30 seconds over and over, after 30 seconds Activate timer2, which will disable timer 1 and press keys in richtextbox 2 once, then wait 10 seconds and activate timer 1 again.

Im extremley new to c# but ive tried using timer 3 to stop timer 2 and start timer 1 again and it just messes it self up. The code ive tried is below. Any help apreciated…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            SendKeys.Send(richTextBox1.Text);
            SendKeys.Send("{ENTER}");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = true;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            SendKeys.Send(richTextBox2.Text);
            SendKeys.Send("{ENTER}"); 
            timer1.Enabled = false;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            timer2.Enabled = false;
        }

        private void richTextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
  • 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-12T14:58:51+00:00Added an answer on May 12, 2026 at 2:58 pm

    I suggest to use just one timer, increment a state counter every second, and perform an action base on the current state.

    public Form1()
    {
        this.InitializeComponent();
    
        // Just to illustrate - can be done in the designer.
        this.timer.Interval = 1000; // One second.
        this.timer.Enable = true;
    }
    
    private Int32 state = 0;
    
    private void timer_Tick(Object sender, EventArgs e)
    {
        if ((0 <= this.state) && (this.state < 30)) // Hit text box 1 30 times.
        {
            SendKeys.Send(this.richTextBox1.Text);
            SendKeys.Send("{ENTER}");
        }
        else if (this.state == 30) // Hit text box 2 once.
        {
            SendKeys.Send(this.richTextBox2.Text);
            SendKeys.Send("{ENTER}");
        }
        else if ((31 <= this.state) && (this.state < 40)) // Do nothing 9 times.
        {
            // Do nothing.
        }
        else
        {
            throw new InvalidOperationException(); // Unexpected state.
        }
    
        // Update state.
        this.state = (this.state + 1) % 40;
    }
    

    The variant with two numeric up down controls.

    public Form1()
    {
        this.InitializeComponent();
    
        // Just to illustrate - can be done in the designer.
        this.timer.Interval = 1000; // One second.
        this.timer.Enable = true;
    }
    
    private Int32 state = 0;
    
    private void timer_Tick(Object sender, EventArgs e)
    {
        Decimal n1 = this.numericUpDown1.Value;
        Decimal n2 = this.numericUpDown2.Value;
    
        if ((0 <= this.state) && (this.state < n1))
        {
            SendKeys.Send(this.richTextBox1.Text);
            SendKeys.Send("{ENTER}");
        }
        else if (this.state == n1)
        {
            SendKeys.Send(this.richTextBox2.Text);
            SendKeys.Send("{ENTER}");
        }
        else if ((n1 <= this.state) && (this.state < n1 + n2))
        {
            // Do nothing.
        }
        else
        {
            // Reset state to resolve race conditions.
            this.state = 0;
        }
    
        // Update state.
        this.state = (this.state + 1) % (n1 + n2);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I'm trying to add a textfield.text entry to an array. I want
Hey guys, I've been trying to build something simple in Flash 8, and I
Hey guys and gals I'm having some major issues trying to get my application
Hey guys I can't seem to get the syntax here right, I'm just trying
Hey guys, I'm trying to get Shadowbox to work. Whenever I click the link,
Hey guys I've been trying all day to get an ant file to automatically
Hey guys Im currently trying to get a textbox a select menu and a
Hey guys I'm trying to write a simple socket program that basically send like
Hey guys, I'm trying to get my head around LINQ and FP, so forgive
Hey guys and girls, i'm stumped. Trying to get array_search to work with this

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.