C#底层键盘勾子类
底层键盘勾子类, 来源网络。
C# Code:
/// KEYBOARD.CS
/// (c) 2006 by Emma Burrows
/// This file contains the following items:
/// - KeyboardHook: class to enable low-level keyboard hook using
/// the Windows API.
/// - KeyboardHookEventHandler: delegate to handle the KeyIntercepted
/// event raised by the KeyboardHook class.
/// - KeyboardHookEventArgs: EventArgs class to contain the information
/// returned by the KeyIntercepted event.
///
/// Change history:
/// 17/06/06: 1.0 - First version.
/// 18/06/06: 1.1 - Modified proc assignment in constructor to make class backward
/// compatible with 2003.
/// 10/07/06: 1.2 - Added support for modifier keys:
/// -Changed filter in HookCallback to WM_KEYUP instead of WM_KEYDOWN
/// -Imported GetKeyState from user32.dll
/// -Moved native DLL imports to a separate internal class as this
/// is a Good Idea according to Microsoft's guidelines
/// 13/02/07: 1.3 - Improved modifier key support:
/// -Added CheckModifiers() method
/// -Deleted LoWord/HiWord methods as they weren't necessary
/// -Implemented Barry Dorman's suggestion to AND GetKeyState
/// values with 0x8000 to get their result
/// 23/03/07: 1.4 - Fixed bug which made the Alt key appear stuck
/// - Changed the line
/// if (nCode >= 0 && (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP))
/// to
/// if (nCode >= 0)
/// {
/// if (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP)
/// ...
/// Many thanks to "Scottie Numbnuts" for the solution.
/// KEYBOARD.CS
/// (c) 2006 by Emma Burrows
/// This file contains the following items:
/// - KeyboardHook: class to enable low-level keyboard hook using
/// the Windows API.
/// - KeyboardHookEventHandler: delegate to handle the KeyIntercepted
/// event raised by the KeyboardHook class.
/// - KeyboardHookEventArgs: EventArgs class to contain the information
/// returned by the KeyIntercepted event.
///
/// Change history:
/// 17/06/06: 1.0 - First version.
/// 18/06/06: 1.1 - Modified proc assignment in constructor to make class backward
/// compatible with 2003.
/// 10/07/06: 1.2 - Added support for modifier keys:
/// -Changed filter in HookCallback to WM_KEYUP instead of WM_KEYDOWN
/// -Imported GetKeyState from user32.dll
/// -Moved native DLL imports to a separate internal class as this
/// is a Good Idea according to Microsoft's guidelines
/// 13/02/07: 1.3 - Improved modifier key support:
/// -Added CheckModifiers() method
/// -Deleted LoWord/HiWord methods as they weren't necessary
/// -Implemented Barry Dorman's suggestion to AND GetKeyState
/// values with 0x8000 to get their result
/// 23/03/07: 1.4 - Fixed bug which made the Alt key appear stuck
/// - Changed the line
/// if (nCode >= 0 && (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP))
/// to
/// if (nCode >= 0)
/// {
/// if (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP)
/// ...
/// Many thanks to "Scottie Numbnuts" for the solution.

参考文档:
其它资料:
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 5.1旗舰版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | 三层体系架构详解 | C/S架构轻量级快速开发框架 | C/S框架网客户案例 | WebApi快速开发框架 | C/S框架代码生成器 | 用户授权注册软件系统 | 版本自动升级软件 | 数据库底层应用框架 | CSFramework.CMS内容管理系统 |
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 5.1旗舰版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | 三层体系架构详解 | C/S架构轻量级快速开发框架 | C/S框架网客户案例 | WebApi快速开发框架 | C/S框架代码生成器 | 用户授权注册软件系统 | 版本自动升级软件 | 数据库底层应用框架 | CSFramework.CMS内容管理系统 |
在线客服
