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

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

C#中色勾子控制键盘

ntPtr.Zero;
internal delegate IntPtr HookHandlerDelegate(
int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam);

/// <summary>
/// Event triggered when a keystroke is intercepted by the
/// low-level hook.
/// </summary>
public event KeyboardHookEventHandler KeyIntercepted;

// Structure returned by the hook whenever a key is pressed
internal struct KBDLLHOOKSTRUCT
{
public int vkCode;
int scanCode;
public int flags;
int time;
int dwExtraInfo;
}

#region Constructors
/// <summary>
/// Sets up a keyboard hook to trap all keystrokes without
/// passing any to other applications.
/// </summary>
public KeyboardHook()
{
proc = new HookHandlerDelegate(HookCallback);
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc,
NativeMethods.GetModuleHandle(curModule.ModuleName), 0);
}
}

/// <summary>
/// Sets up a keyboard hook with custom parameters.
/// </summary>
/// <param name="param">A valid name from the Parameter enum; otherwise, the
/// default parameter Parameter.None will be used.</param>
public KeyboardHook(string param)
: this()
{
if (!String.IsNullOrEmpty(param) && Enum.IsDefined(typeof(Parameters), param))
{
SetParameters((Parameters)Enum.Parse(typeof(Parameters), param));
}
}

/// <summary>
/// Sets up a keyboard hook with custom parameters.
/// </summary>
/// <param name="param">A value from the Parameters enum.</param>
public KeyboardHook(Parameters param)
: this()
{
SetParameters(param);
}

private void SetParameters(Parameters param)
{
switch (param)
{
case Parameters.None:
break;
case Parameters.AllowAltTab:
AllowAltTab = true;
break;
case Parameters.AllowWindowsKey:
AllowWindowsKey = true;
break;
case Parameters.AllowAltTabAndWindows:
AllowAltTab = true;
AllowWindowsKey = true;
break;
case Parameters.PassAllKeysToNextApp:
PassAllKeysToNextApp = true;
break;
}
}
#endregion

#region Check Modifier keys
/// <summary>
/// Checks whether Alt, Shift, Control or CapsLock
/// is enabled at the same time as another key.
/// Modify the relevant sections and return type
/// depending on what you want to do with modifier keys.
/// </summary>
private void CheckModifiers()
{
StringBuilder sb = new StringBuilder();

if ((N

上一页第2页

你可能喜欢

热门文档

相关文档

  • 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