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

推荐订阅源

P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
腾讯CDC
人人都是产品经理
人人都是产品经理
小众软件
小众软件
V
Visual Studio Blog
S
Secure Thoughts
J
Java Code Geeks
V
V2EX
量子位
The Hacker News
The Hacker News
酷 壳 – CoolShell
酷 壳 – CoolShell
Security Latest
Security Latest
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tailwind CSS Blog
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
T
Tenable Blog
S
Security @ Cisco Blogs
月光博客
月光博客
雷峰网
雷峰网
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
博客园 - 三生石上(FineUI控件)
Hacker News - Newest:
Hacker News - Newest: "LLM"
有赞技术团队
有赞技术团队
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
TaoSecurity Blog
TaoSecurity Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
K
Kaspersky official blog

博客园 - HackerVirus

在window系统下搭建C/C++开发环境 C#中DataGridView处理大数据量的技巧分享 CSharp-MVVM框架 多线程&线程池 Prism的事件聚合器 Windsurf:超越 Cursor 的下一代 AI 编辑器 编程辅助新选择:Devin与Cursor的性能对比评测 支持多语言、多商店的商城,.Net7 + EF7领域驱动设计架构 Mysql高可用架构方案 软件架构中的那些惯用手段 .Net轻量级的CMS开源项目 前后端分离的权限管理框架,前端采用 Vue 3 框架,后端采用 .NET 8、ORM 采用 EF 8 linux文件属性 Roslyn的源生成器 IHostedService 和 BackgroundService 区别 Uno Platform是一个基于C#开源、功能强大、灵活的跨平台开发框架,用于快速构建单一代码库原生移动、Web、桌面和嵌入式应用程序 使用HslCommunication类库读取Siemens PLC DATA 功能齐全的 WPF 自定义控件 Sprint Planning
Toggling Focus Assist mode in Win 10 Programmatically
HackerVirus · 2025-07-22 · via 博客园 - HackerVirus
 1 using System.Diagnostics;
 2 using System.Runtime.InteropServices;
 3 
 4 namespace ConsoleApp1
 5 {
 6     internal class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             Console.WriteLine("Hello, World!");
11             var state = WnfHelper.GetFocusAssistValue();
12             Console.WriteLine($"{state.ToString()}");
13             Console.ReadLine();
14         }
15     }
16 
17     public static class WnfHelper
18     {
19         public const ulong WNF_SHEL_QUIETHOURS_ACTIVE_PROFILE_CHANGED = 0x0d83063ea3bf1c75UL;
20 
21         [StructLayout(LayoutKind.Sequential)]
22         private struct WNF_STATE_NAME
23         {
24             public uint Data1;
25 
26             public uint Data2;
27         }
28 
29         [DllImport("ntdll.dll", SetLastError = true)]
30         private static extern int NtQueryWnfStateData(
31                                         ref ulong stateName,
32                                         IntPtr typeId,
33                                         IntPtr explicitScope,
34                                         out uint changeStamp,
35                                         byte[] buffer,
36                                         ref uint bufferSize);
37 
38         public static FocusAssistState GetFocusAssistValue()
39         {
40             return
41                 (FocusAssistState)
42                     GetWnfStateValue(
43                             WNF_SHEL_QUIETHOURS_ACTIVE_PROFILE_CHANGED);
44         }
45 
46         public static int GetWnfStateValue(ulong stateNameIdent)
47         {
48             var buffer = new byte[4];  // DWORD
49             var bufferSize = (uint)buffer.Length;
50 
51             var status =
52                 NtQueryWnfStateData(
53                         ref stateNameIdent,
54                         IntPtr.Zero,
55                         IntPtr.Zero,
56                         out var changeStamp,
57                         buffer,
58                         ref bufferSize);
59 
60             if (status == 0)
61             {
62                 var mode = BitConverter.ToInt32(buffer, 0);
63 
64                 Debug.WriteLine($"Mode:  '{mode}'");
65 
66                 return mode;
67             }
68             else
69             {
70                 Debug.WriteLine($"Failed to read the state value. 'NTSTATUS': '0x{status:X8}'");
71             }
72 
73             return -1;
74         }
75     }
76 
77     public enum FocusAssistState : uint
78     {
79         Off = 0,
80         Game = 1,
81         Fullscreen = 2,
82     }
83 }

https://martinsuchan.github.io/ApiPeek/Diffs/win11.22526.to.win11.22572.fulldiff.html

https://helpdeskgeek.com/what-is-focus-assist-in-windows-11-and-how-to-use-it/

https://stackoverflow.com/questions/55477041/toggling-focus-assist-mode-in-win-10-programmatically