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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:42:50+00:00 2026-06-13T23:42:50+00:00

The program comes to the page and makes pressing buttons using System; using System.Collections.Generic;

  • 0

The program comes to the page and makes pressing buttons

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 Bot
{
    public partial class FormWindow : Form
    {
        Random rnd;
        Settings settingsForm;
        Timer tm;
        CallTimers callTimers;

        public FormWindow()
        {
            rnd = new Random();
            settingsForm = new Settings();
            tm = new Timer();
            tm.Tick += new EventHandler(tm_Tick);
            wb = new WebBrowser();
            InitializeComponent();
        }

        private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (wb.Document.GetElementById("login-email") != null)
            {
                wb.Document.GetElementById("login-email").InnerText = settingsForm.tEmail.Text;
                wb.Document.GetElementById("login-password").InnerText = settingsForm.tPassword.Text;
                Method_1("button luxury")[0].InvokeMember("click");
            }

               CallMethodAfterDelay(KrysomahHunting, 5000, tm);

                if (wb.Url.AbsoluteUri == "http://www.moswar.ru/metro/" && wb.ReadyState == WebBrowserReadyState.Complete)
                {
                    wb.Stop();
                    method_2("c", "Выследить Крысомаху")[0].InvokeMember("click");
                    Method_1(new string[] { "button" })[0].InvokeMember("click");
                }
        }

        //go to page 
        public void GoPage(string string_9, string string_10)
        {
            this.wb.Stop();
            string additionalHeaders = "Content-Type: application/x-www-form-urlencoded" + Environment.NewLine;
            this.wb.Navigate(string_9, "", Encoding.UTF8.GetBytes(string_10), additionalHeaders);
        }


        public List<HtmlElement> Method_1(params string[] ClassNames)
        {
            List<HtmlElement> list = new List<HtmlElement>();
            foreach (HtmlElement htmlElement in wb.Document.All)
            {
                for (int i = 0; i < ClassNames.Length; i++)
                {
                    string b = ClassNames[i];
                    if (htmlElement.GetAttribute("className") == b)
                    {
                        list.Add(htmlElement);
                        break;
                    }
                }
            }
            return list;
        }


        private void ButtonStart_Click(object sender, EventArgs e)
        {
            if (this.settingsForm.tEmail.Text == "" || this.settingsForm.tPassword.Text == "")
            {
                MessageBox.Show("Отсутствует логин и\\или пароль для входа на сервер МосВара.\nВвести их можно, нажав на кнопку \"Настройки\".", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            wb.Navigate("http://www.moswar.ru");
        }

        private void tm_Tick(object sender, EventArgs e)
        {
            ((MethodInvoker)tm.Tag).Invoke();
            tm.Stop();
        }

        //go to page through time 
         public void CallMethodAfterDelay(MethodInvoker MethodToCall, int Delay,Timer tm)
       {
           tm.Interval = Delay;
           tm.Tag = MethodToCall;
           tm.Start();
       }
        public void KrysomahHunting()
        {
            GoPage("http://www.moswar.ru/metro/", "");
        }

        private List<HtmlElement> method_2(string string_9, string string_10)
        {
            List<HtmlElement> list = new List<HtmlElement>();
            foreach (HtmlElement htmlElement in this.wb.Document.All)
            {
                if (htmlElement.GetAttribute("className") == string_9 && htmlElement.InnerText != null && htmlElement.InnerText.IndexOf(string_10) != -1)
                {
                    list.Add(htmlElement);
                }
            }
            return list;
        }

    }
}

Help how to articulate the logic

In this piece of code

private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (wb.Document.GetElementById("login-email") != null)
            {
                wb.Document.GetElementById("login-email").InnerText = settingsForm.tEmail.Text;
                wb.Document.GetElementById("login-password").InnerText = settingsForm.tPassword.Text;
                Method_1("button luxury")[0].InvokeMember("click");
            }

               CallMethodAfterDelay(KrysomahHunting, 5000, tm);

                if (wb.Url.AbsoluteUri == "http://www.moswar.ru/metro/" && wb.ReadyState == WebBrowserReadyState.Complete)
                {
                    wb.Stop();
                    method_2("c", "Выследить Крысомаху")[0].InvokeMember("click");
                    Method_1(new string[] { "button" })[0].InvokeMember("click");
                }

        }

When the program comes to the method

method_2("c", "Выследить Крысомаху")[0].InvokeMember("click");

throws Exception ArgumentOutRangeException

I supposethat this couldbe caused by

private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

Heconstantly checks.Ifapagethatexecute methods .And because the method once already done its job, there is no longer the values

And so we get an exception ArgumentOutRangeException. Help how to make the logic for this case!

  • 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-06-13T23:42:51+00:00Added an answer on June 13, 2026 at 11:42 pm

    What if you add a check in on that method call?

    var method2 = method_2("c", "...");
    if (method2.Count > 0)
        method2[0].InvokeMember("click");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the sample program, which comes with Google Data API. I
Here are the full codes that I am using to implement this program. Everything
I'm using WMI to retrieve information about physical drives on the system: SELECT *
I have a problem with python-config --ldflags on OS X 10.6.2. Using my non-system
// Program to print simple text on a Printer import javax.swing.*; import java.awt.*; import
Inspired by the top answer on this page I wrote a python program to
I'm using Web-Harvest to extract some data from a site. Site gets a POST
I am capturing some events in a C# program that come back with the
I've recently come across a C program in which the main function only took
what C++ codes could i add to my program which will actually freeze my

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.