文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 高等教育 > 哲学 > C#勾子解决方案(使用时请先重命后缀CS)
侵权投诉

C#勾子解决方案(使用时请先重命后缀CS)

C#中色勾子控制键盘

/// 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.


using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;

/// <summary>
/// Low-level keyboard intercept class to trap and suppress system keys.
/// </summary>
public class KeyboardHook : IDisposable
{
/// <summary>
/// Parameters accepted by the KeyboardHook constructor.
/// </summary>
public enum Parameters
{
None,
AllowAltTab,
AllowWindowsKey,
AllowAltTabAndWindows,
PassAllKeysToNextApp
}

//Internal parameters
private bool PassAllKeysToNextApp = false;
private bool AllowAltTab = false;
private bool AllowWindowsKey = false;

//Keyboard API constants
private const int WH_KEYBOARD_LL = 13;
private const int WM_KEYUP = 0x0101;
private const int WM_SYSKEYUP = 0x0105;

//Modifier key constants
private const int VK_SHIFT = 0x10;
private const int VK_CONTROL = 0x11;
private const int VK_MENU = 0x12;
private const int VK_CAPITAL = 0x14;

//Variables used in the call to SetWindowsHookEx
private HookHandlerDelegate proc;
private IntPtr hookID = I

第1页

你可能喜欢

热门文档

相关文档

  • C#开发常见的文件名后缀

    其中常见的文件名后缀及其功能如下: .sln:解决方案文件,为解决方案资源管理器....csproj:项目文件,创建应用程序所需的引用、数据连接、文件夹和文件的信息。 ....

  • 301重定向后出现后缀eurl解决方案

    301重定向后出现后缀eurl解决方案_互联网_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 301重定向后出现后缀eurl解决方案_互联网_IT/计算机_专业资料。...

  • ASPNET中各个后缀名意思

    ASPNET中各个后缀名意思_计算机软件及应用_IT/计算机_专业资料。ASPNET中各个...2 3 4 .sln: .csproj: .aspx: 解决方案文件,为解决方案资源管理器提供显示...

  • c#5

    (.cs后缀的 文件),分别是Forml.cs、Forml.Designer...在解决方案资源管理器中,右击项目LoginApp,在弹出的... saveFileDialog1.InitialDirectory = "c:"; ...

  • 三恩信息技术网络考试系统(CS版)常见问题及解决方法

    三恩信息技术网络考试系统(CS版)常见问题及解决方法_计算机硬件及网络_IT/计算机_专业资料。三恩信息技术网络考试系统(C/S)常见问题及解决方法序号 1 问题现象 ...

  • cs参数

    cs参数。cs参数详解使用最真实的弹道--学会设置...禁用对玩家模型的光滑处理,从而提高fps (以上7个...想提高fps最好的办法就是买新电脑 ! 今日推荐 ...

  • 使用C#和BlockUI进行UG二次开发

    将 dlx 和 cs 文件保存到 application 文件夹下。...2.7 生成解决方案 3.MenuScript 的编写 3.1 在 ...新建 myTest.txt 的文本文件,然后修改后缀为 men,...

  • C#复习

    文件结构:各种文件的后缀名: ? ? ? ? ? ? ? ? ? ? .sln:解决方案文件,为解决方案资源管理器提供显示管理文件的图形接口所需的 信息。 .csproj:项目文件...

  • C#复习

    文件结构:各种文件的后缀名: ? ? ? ? ? ? ? ? ? ? .sln:解决方案文件,为解决方案资源管理器提供显示管理文件的图形接口所 需的信息。 .csproj:项目文件...

  • C#习题二

    扩展名是 A.cs ( B. csproj C. suo D. sln )2, 某文件的后缀是 cs,...错误打Ⅹ) 判断题 正确打 2 ( ( ( ( )1>一个解决方案可以由 C#项目和 ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email