title: Auto click button in winform c#
body: <p>I have a button code that enable the connection to the network whenever the user click it.  </p>
  
  <pre><code>private void cmdConnect_Click(object sender, System.EventArgs e)
      {
          try
          {
              EnableCommands(true);
              //Creating instance of Socket
              m_socClient = new Socket (AddressFamily.InterNetwork,SocketType.Stream ,ProtocolType.Tcp );
  
              // retrieve the remote machines IP address
              IPAddress ip = IPAddress.Parse (txtIPAddr.Text);
              //A printer has open port 9100 which can be used to connect to printer
              int iPortNo = System.Convert.ToInt16 ( txtPort.Text);
              //create the end point 
              IPEndPoint ipEnd = new IPEndPoint (ip.Address,iPortNo);
              //connect to the remote host
              m_socClient.Connect ( ipEnd );
              EnableCommands(false);
              //wait for data to arrive 
              WaitForData();
          }
          catch(SocketException se)
          {
              MessageBox.Show (se.Message );
              EnableCommands(true);
          }
  
          page_counter();
      }  
  </code></pre>
  
  <p>However now I want this code to auto run first without anyone click on it. I want to do this because I want the task scheduler to run this code everyday to do update. This program will run behind, and theres no interaction with users. Therefore I want this program to auto connect by itself. Is this possible? Please advise.</p>