惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
大猫的无限游戏
大猫的无限游戏
NISL@THU
NISL@THU
Scott Helme
Scott Helme
G
Google Developers Blog
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Cloudflare Blog
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cisco Blogs
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Forbes - Security
Forbes - Security
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
S
Security Affairs
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy & Cybersecurity Law Blog
Martin Fowler
Martin Fowler
Know Your Adversary
Know Your Adversary
F
Full Disclosure
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
博客园 - Franky
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
T
Tenable Blog
V
V2EX
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

博客园 - chengeng

让SVN可以修改提交log Python开发环境搭建 ubuntu 安装mysql Android Studio汉化备忘 DataConvert VS2022,IF条件为Flase也进入断点,设置方法 在CentOS上,查看CPU、内存和磁盘的指标命令 mysql 常用语句 MQTT服务器订阅消息例子 Java 异步调用方法 修改Web.config,IIS启动速度提升60倍 Windows smbv1共享协议开启 windows 10 激活 c#将一个类型对象数据赋值到另一个类型对象(名字相同的情况) 根据json内容更新表的一行,字段数量不固定,但名称需要一致 Windows 服务启动共享目录 FastReport 打印弹框,无法关闭(自己特定的场景,做个备忘,请勿参考) MDns C# 实现 Makaretu.Dns.Multicast WinForm截屏 C#根据json内容动态生成SQL语句,字段数量可以不一样 金蝶云星空BOS平台官网知识 .Net Framework 离线安装包
WinForm 指定时间没有操作键盘鼠标,弹出屏幕保护
chengeng · 2024-03-18 · via 博客园 - chengeng
 #region 屏幕保护
 System.Timers.Timer timerRunScreenSaverTask = null;
 F_ScreenSaver f_ScreenSaver = null;
 private void RunScreenSaverTask() 
 {
     if (timerRunScreenSaverTask == null)
     {
         timerRunScreenSaverTask = new System.Timers.Timer();
         timerRunScreenSaverTask.Interval = 1000;
         timerRunScreenSaverTask.Elapsed += TimerRunScreenSaverTask_Elapsed;
         timerRunScreenSaverTask.Start();
     }
 }

 private void TimerRunScreenSaverTask_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     RunScreenSaver();
 }

 private void RunScreenSaver() 
 {
     long lastInputTimeToNow = GetLastInputTime();
     if (lastInputTimeToNow >= 5 * 1000)
     {
         Console.WriteLine("走If分支" + "空闲时间" + lastInputTimeToNow.ToString());
         string imagePath = Application.StartupPath + @"\Update\ScreenSaver.png";
         if (File.Exists(imagePath) == false)
         {
             return;
         }

         if (f_ScreenSaver == null)
         {
             f_ScreenSaver = new F_ScreenSaver();
             f_ScreenSaver.TopLevel = true;
             f_ScreenSaver.ShowDialog();
         }
         else
         {
             f_ScreenSaver.ShowDialog();
         }
     }
     else
     {
         Console.WriteLine("走else分支" + "空闲时间" + lastInputTimeToNow.ToString());
         if (f_ScreenSaver != null)
         {
             f_ScreenSaver.Hide();
         }
     }
 }

 [DllImport("user32.dll")]
 static extern bool GetLastInputInfo(ref LastInputInfo plii);
 static long GetLastInputTime()
 {
     LastInputInfo vLastInputInfo = new LastInputInfo();
     vLastInputInfo.Size = Marshal.SizeOf(vLastInputInfo);
     if (!GetLastInputInfo(ref vLastInputInfo)) return 0;
     return Environment.TickCount - (long)vLastInputInfo.Time;
 }

 [StructLayout(LayoutKind.Sequential)]
 struct LastInputInfo
 {
     [MarshalAs(UnmanagedType.U4)]
     public int Size;
     [MarshalAs(UnmanagedType.U4)]
     public uint Time;
 }
 #endregion

posted @ 2024-03-18 10:50  chengeng  阅读(90)  评论()    收藏  举报