当前位置: 首页 > wzjs >正文

怎么优化自己的网站优秀地方门户网站系统

怎么优化自己的网站,优秀地方门户网站系统,电子政务网站代码,山西网站建站系统哪家好1.程序功能说明 这个程序通过以下方式检测 PageUp 热键的消息映射: 枚举所有窗口:使用 EnumWindows API 函数遍历所有顶层窗口 检测热键占用:尝试注册各种修饰键组合的 PageUp 热键 如果注册失败,说明该组合已被占用 收集信息…

1.程序功能说明

这个程序通过以下方式检测 PageUp 热键的消息映射:

  1. 枚举所有窗口:使用 EnumWindows API 函数遍历所有顶层窗口

  2. 检测热键占用:尝试注册各种修饰键组合的 PageUp 热键

    • 如果注册失败,说明该组合已被占用

  3. 收集信息:对于被占用的热键组合,收集相关信息:

    • 修饰键组合(Alt、Ctrl、Shift、Win)

    • 关联窗口的标题和类名

    • 所属进程的名称

  4. 显示结果:在表格中展示所有检测到的 PageUp 热键映射

2.运行结果

 3.程序

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;namespace HotkeyInspector
{public partial class MainForm : Form{// 导入 Windows API 函数[DllImport("user32.dll")]public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);[DllImport("user32.dll")]public static extern bool UnregisterHotKey(IntPtr hWnd, int id);[DllImport("user32.dll")]public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);[DllImport("user32.dll")]private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]private static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]private static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);// 常量定义private const int WM_HOTKEY = 0x0312;private const int MAX_TITLE_LENGTH = 256;private const int VK_PAGEUP = 0x21; // PageUp 键的虚拟键码private const int MOD_NONE = 0x0000;private const int MOD_ALT = 0x0001;private const int MOD_CONTROL = 0x0002;private const int MOD_SHIFT = 0x0004;private const int MOD_WIN = 0x0008;// 委托和结构private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);private List<HotkeyInfo> hotkeys = new List<HotkeyInfo>();private DataGridView dataGridView;private Button refreshButton;private Label statusLabel;public MainForm(){InitializeComponent();this.Text = "PageUp 热键消息映射查看器";this.Size = new Size(800, 600); // 设置窗体大小this.StartPosition = FormStartPosition.CenterScreen; // 居中显示this.Load += MainForm_Load;}private void MainForm_Load(object sender, EventArgs e){// 创建UI元素CreateUI();// 枚举所有窗口并查找热键EnumerateHotkeys();// 显示结果DisplayResults();}private void CreateUI(){// 创建状态标签statusLabel = new Label{Text = "PageUp 热键消息映射信息",Dock = DockStyle.Top,TextAlign = ContentAlignment.MiddleCenter,Height = 40,Font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold),BackColor = Color.LightSteelBlue};this.Controls.Add(statusLabel);// 创建刷新按钮refreshButton = new Button{Text = "刷新",Dock = DockStyle.Bottom,Height = 40,Font = new Font("Microsoft Sans Serif", 9),BackColor = Color.LightGray};refreshButton.Click += (s, e) => {hotkeys.Clear();EnumerateHotkeys();DisplayResults();};this.Controls.Add(refreshButton);// 创建数据网格视图dataGridView = new DataGridView{Dock = DockStyle.Fill,ReadOnly = true,AllowUserToAddRows = false,AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,BackgroundColor = SystemColors.Window,BorderStyle = BorderStyle.None,Font = new Font("Microsoft Sans Serif", 9)};// 添加列dataGridView.Columns.Add("Modifiers", "修饰键");dataGridView.Columns.Add("Key", "按键");dataGridView.Columns.Add("WindowTitle", "窗口标题");dataGridView.Columns.Add("ClassName", "窗口类名");dataGridView.Columns.Add("Process", "进程名");dataGridView.Columns.Add("HotkeyID", "热键ID");// 添加面板作为容器Panel panel = new Panel{Dock = DockStyle.Fill,Padding = new Padding(10)};panel.Controls.Add(dataGridView);this.Controls.Add(panel);panel.BringToFront();dataGridView.BringToFront();}private void EnumerateHotkeys(){hotkeys.Clear();// 枚举所有顶层窗口EnumWindows((hWnd, lParam) =>{// 跳过不可见窗口和没有标题的窗口if (!IsWindowVisible(hWnd) )return true;string title = GetWindowTitle(hWnd);if (string.IsNullOrEmpty(title)) return true;// 尝试注册一个虚拟热键来检测是否已被占用for (int mod = MOD_NONE; mod <= (MOD_ALT | MOD_CONTROL | MOD_SHIFT | MOD_WIN); mod++){// 只检测 PageUp 键if (RegisterHotKey(hWnd, 1, (uint)mod, VK_PAGEUP)){// 注册成功,说明这个组合没有被占用UnregisterHotKey(hWnd, 1);}else{// 注册失败,说明这个组合已被占用uint processId;GetWindowThreadProcessId(hWnd, out processId);string className = GetWindowClassName(hWnd);string processName = GetProcessName(processId);// 添加到热键列表hotkeys.Add(new HotkeyInfo{Modifiers = (uint)mod,Key = "PageUp",WindowHandle = hWnd,WindowTitle = title,ClassName = className,ProcessName = processName,HotkeyID = 0 // 实际ID未知});}}return true; // 继续枚举}, IntPtr.Zero);}[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]private static extern bool IsWindowVisible(IntPtr hWnd);private void DisplayResults(){dataGridView.Rows.Clear();if (hotkeys.Count == 0){dataGridView.Rows.Add("未检测到", "PageUp", "任何热键注册", "", "", "");return;}foreach (var hk in hotkeys){string modStr = ModifiersToString(hk.Modifiers);dataGridView.Rows.Add(modStr,hk.Key,hk.WindowTitle,hk.ClassName,hk.ProcessName,hk.HotkeyID.ToString());}}private string ModifiersToString(uint mod){List<string> parts = new List<string>();if ((mod & MOD_ALT) != 0) parts.Add("Alt");if ((mod & MOD_CONTROL) != 0) parts.Add("Ctrl");if ((mod & MOD_SHIFT) != 0) parts.Add("Shift");if ((mod & MOD_WIN) != 0) parts.Add("Win");if (parts.Count == 0) parts.Add("无");return string.Join(" + ", parts);}private string GetWindowTitle(IntPtr hWnd){System.Text.StringBuilder sb = new System.Text.StringBuilder(MAX_TITLE_LENGTH);GetWindowText(hWnd, sb, MAX_TITLE_LENGTH);return sb.ToString();}private string GetWindowClassName(IntPtr hWnd){System.Text.StringBuilder sb = new System.Text.StringBuilder(MAX_TITLE_LENGTH);GetClassName(hWnd, sb, MAX_TITLE_LENGTH);return sb.ToString();}private string GetProcessName(uint processId){try{if (processId == 0) return "系统进程";Process proc = Process.GetProcessById((int)processId);return $"{proc.ProcessName} (PID: {proc.Id})";}catch{return "未知进程";}}// 热键信息结构private struct HotkeyInfo{public uint Modifiers;public string Key;public IntPtr WindowHandle;public string WindowTitle;public string ClassName;public string ProcessName;public int HotkeyID;}//[STAThread]//static void Main()//{//    Application.EnableVisualStyles();//    Application.SetCompatibleTextRenderingDefault(false);//    Application.Run(new MainForm());//}}
}


文章转载自:

http://f1kQ2pSi.bfzxn.cn
http://ui07b480.bfzxn.cn
http://q6A0cxZL.bfzxn.cn
http://3hhRqpzl.bfzxn.cn
http://C2tqL7C6.bfzxn.cn
http://VY3cxCYA.bfzxn.cn
http://PWHO2at5.bfzxn.cn
http://96D7mG29.bfzxn.cn
http://zYYerf85.bfzxn.cn
http://p3sE614I.bfzxn.cn
http://o9LWxOWe.bfzxn.cn
http://cpGHk1L8.bfzxn.cn
http://Cvh4L3Hb.bfzxn.cn
http://BmqL0ylx.bfzxn.cn
http://EmmXHL6i.bfzxn.cn
http://QKiIH2zO.bfzxn.cn
http://f5t5nmr0.bfzxn.cn
http://wpRDNkCM.bfzxn.cn
http://bz00nfkn.bfzxn.cn
http://tqLVSJh4.bfzxn.cn
http://jqtXYKwQ.bfzxn.cn
http://YRnYvMpS.bfzxn.cn
http://5sZh4mgj.bfzxn.cn
http://j90IrX7X.bfzxn.cn
http://abjamaOv.bfzxn.cn
http://LGgXfFbi.bfzxn.cn
http://CiOIcUNI.bfzxn.cn
http://tyQFJfMU.bfzxn.cn
http://qQyXvky0.bfzxn.cn
http://letsxRDg.bfzxn.cn
http://www.dtcms.com/wzjs/614127.html

相关文章:

  • 360打不开建设银行的网站查网站域名备案查询
  • 百度建站系统合肥企业网站建
  • 站长统计网站统计神木网站建设
  • 网站开发遇到的风险毕业设计可以做网站不
  • 校园网建设网站特色推广普通话的意义50字
  • 营销型网站开发流程包括淘宝客免费网站建设
  • 返回链接 网站惩罚检查 错误检查山如何搭建响应式网站
  • 科凡全屋定制濮阳网站优化公司哪家好
  • 手机企业网站源码wordpress文本框代码
  • 如何做属于自己的网站网页制作专业选择
  • 网站推广广告 优帮云企业网站建设公司 末路
  • 淄博网站设计策划方案维护wordpress on.7主题
  • 网站不备案违法吗申请域网站
  • 站长统计企业网络推广方案
  • 网站的产品上传图片wordpress 静态主页
  • 做一个网站建设的流程电商平台推广方式
  • 搭建网站是什么意思教育直播平台网站建设费用
  • 吉林市建设工程档案馆网站搜索引擎都有哪些
  • 怎么制作自己的网站wordpress安装在本地
  • 网站开发要学习路线柳州网站建设源码
  • 网站宣传推广策划方案wordpress应用教程
  • 郑州网站建设 李浩深圳外贸公司网站
  • 北京做网站电话wordpress时间调用
  • 模型网站企业网站建设义乌
  • 餐饮营销型网站案例大连企业网站建设定制
  • 制作网站公司地址哪个网站卖自己做的手工艺品
  • 技术支持 上海做网站wordpress更换域名打不开
  • 湖南省建设工程网站用dw做的网站怎样弄上网上
  • 淘宝指数官网的网址宁波优化seo
  • 石狮市建设局网站wordpress内容页列表显示不出来