C#实现简单屏幕监控的方法
作者:igoo 时间:2023-07-31 10:29:25
本文实例讲述了C#实现简单屏幕监控的方法。分享给大家供大家参考。具体如下:
这是一段C#编写的屏幕监控代码,可以自动对屏幕进行截图,软件自身隐藏
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Screen
{
public partial class Form1 : Form
{
public Form1()
{
//主窗体桌面不显示 仅在进程中显示
InitializeComponent();
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
SetVisibleCore(false);
}
protected override void SetVisibleCore(bool value)
{
base.SetVisibleCore(value);
}
private void timer1_Tick(object sender, EventArgs e)
{
//获得当前屏幕的大小
Rectangle rect = new Rectangle();
rect = System.Windows.Forms.Screen.GetWorkingArea(this);
Size mySize = new Size(rect.Width, rect.Height);
Bitmap bitmap = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(0, 0, 0, 0, mySize);
string ImageName = DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".jpg";
bitmap.Save("F://screen//" + ImageName);
//释放资源
bitmap.Dispose();
g.Dispose();
GC.Collect();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;//激活timer控件
}
}
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,屏幕,监控
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#模拟实现抽奖小程序的示例代码
2021-08-27 22:19:17
![](https://img.aspxhome.com/file/2023/0/78130_0s.jpg)
Java标识接口的使用方法
2021-12-24 02:54:14
WPF MVVM示例讲解
2022-04-16 22:47:20
![](https://img.aspxhome.com/file/2023/7/102257_0s.png)
Java实现简单文件过滤器功能
2021-09-13 23:27:58
![](https://img.aspxhome.com/file/2023/1/62111_0s.png)
Android WebView 常见问题及处理方案
2023-04-13 04:11:57
java实现二叉树的创建及5种遍历方法(总结)
2022-03-14 09:00:28
Android编程开发之NotiFication用法详解
2023-01-19 22:50:11
![](https://img.aspxhome.com/file/2023/4/105994_0s.png)
Java把数字格式化为货币字符串实例代码
2022-10-13 23:17:27
![](https://img.aspxhome.com/file/2023/8/92688_0s.png)
Java获取Process子进程进程ID方法详解
2022-09-01 13:21:08
![](https://img.aspxhome.com/file/2023/7/105947_0s.png)
Android指纹解锁方法解析
2023-06-27 15:37:58
Android自定义有限制区域图例角度自识别涂鸦工具类中篇
2021-06-16 16:21:46
![](https://img.aspxhome.com/file/2023/8/138508_0s.jpg)
命令提示符编译java的方法(必看篇)
2022-01-28 08:34:38
![](https://img.aspxhome.com/file/2023/8/83568_0s.png)
Spring实现内置监听器
2021-07-06 01:29:06
![](https://img.aspxhome.com/file/2023/8/63318_0s.png)
详解xamarin Android 实现ListView万能适配器
2022-11-26 02:12:33
C#中隐式运行CMD命令行窗口的方法
2021-06-11 18:47:07
SpringBoot 整合 Shiro 密码登录的实现代码
2023-11-10 11:27:59
Java xml出现错误 javax.xml.transform.TransformerException: java.lang.NullPointerException
2023-11-08 14:48:13
Android实现手机震动效果
2022-11-05 12:20:43
c#多线程之线程基础
2022-10-06 20:34:44
C#实现FTP传送文件的示例
2022-06-24 01:15:20