Programın çalışması
Öncelikle siteler adında bir string tipinde dizi tanımlıyoruz.Bu dizi website isimlerini tutuyor.Int tipinde bir sayac ile dizimizin uzunluğunu tutarak hata vermesini engelliyoruz.
Form un load kısmında timer nesnesini aktif hale getirip Interval değerini 10 sn olarak tanımlıyoruz 10 sn geçtikten sonra PerformClick() metodu ile butonumuza otomatik tıklattıyoruz.Aslına bakarsanız iş burda bitiyor.
SiteAc fonksiyonunuda ise tarayıcımıza gönderilen site ismini varsayılan browser da açıyor.Genel hatlarıyla çalışması bu şekilde.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoClick
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Değişkenler burda tanımlanır
public int Sayac = 0;
#region Siteler
public string[] Siteler =
{
"http://www.gezginnerede.com",
"http://www.jetsethayat.com",
"http://www.hanedancity.com",
"http://www.halil-sahin.blogspot.com",
"http://www.facebook.com/sshneo",
"http://www.hurriyet.com.tr",
"http://www.mynet.com",
"http://www.linkedin.com",
"https://twitter.com/sshneo",
"http://www.goodreads.com/sshneo",
};
#endregion
public void SiteAc(string SiteAdi)
{
System.Diagnostics.Process.Start(SiteAdi);
}
private void timer1_Tick_1(object sender, EventArgs e)
{
if (Sayac > Siteler.Length-1)
{
timer1.Enabled = false;
textBox1.Text = "Görev Tamamlandı...";
textBox1.BorderStyle = BorderStyle.None;
textBox1.BackColor = Color.Green;
button1.Text = "OK..";
Sayac = 0;
}
else
{
textBox1.Text = "";
textBox1.Text = Siteler[Sayac];
listBox1.Items.Add("Açılan Site : " + Siteler[Sayac]);
listBox1.Items.Add("Timer Aktif Oldu");
button1.Focus();
listBox1.Items.Add("Buton 1 Focuslandı");
listBox1.Items.Add("Butona Tıklandı");
button1.Text = "Tıklandı........";
button1.PerformClick();
button1.Text = "Bekleniyor";
label1.Text = (Sayac + 1).ToString();
}
Sayac++;
}
private void button1_Click_1(object sender, EventArgs e)
{
string SiteAdi = Siteler[Sayac];
SiteAc(SiteAdi);
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.BackColor = Color.Red;
textBox1.ForeColor = Color.White;
button1.Text = "Yükleniyor...";
label1.Text = "";
timer1.Enabled = true;
timer1.Interval = 10000;
listBox1.Items.Add("Program Yüklendi.");
listBox1.Items.Add("10 sn sonra çalışmaya başlıcak.");
}
}
}