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
其中常见的文件名后缀及其功能如下: .sln:解决方案文件,为解决方案资源管理器....csproj:项目文件,创建应用程序所需的引用、数据连接、文件夹和文件的信息。 ....
301重定向后出现后缀eurl解决方案_互联网_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 301重定向后出现后缀eurl解决方案_互联网_IT/计算机_专业资料。...
ASPNET中各个后缀名意思_计算机软件及应用_IT/计算机_专业资料。ASPNET中各个...2 3 4 .sln: .csproj: .aspx: 解决方案文件,为解决方案资源管理器提供显示...
(.cs后缀的 文件),分别是Forml.cs、Forml.Designer...在解决方案资源管理器中,右击项目LoginApp,在弹出的... saveFileDialog1.InitialDirectory = "c:"; ...
三恩信息技术网络考试系统(CS版)常见问题及解决方法_计算机硬件及网络_IT/计算机_专业资料。三恩信息技术网络考试系统(C/S)常见问题及解决方法序号 1 问题现象 ...
cs参数。cs参数详解使用最真实的弹道--学会设置...禁用对玩家模型的光滑处理,从而提高fps (以上7个...想提高fps最好的办法就是买新电脑 ! 今日推荐 ...
将 dlx 和 cs 文件保存到 application 文件夹下。...2.7 生成解决方案 3.MenuScript 的编写 3.1 在 ...新建 myTest.txt 的文本文件,然后修改后缀为 men,...
文件结构:各种文件的后缀名: ? ? ? ? ? ? ? ? ? ? .sln:解决方案文件,为解决方案资源管理器提供显示管理文件的图形接口所需的 信息。 .csproj:项目文件...
文件结构:各种文件的后缀名: ? ? ? ? ? ? ? ? ? ? .sln:解决方案文件,为解决方案资源管理器提供显示管理文件的图形接口所 需的信息。 .csproj:项目文件...
扩展名是 A.cs ( B. csproj C. suo D. sln )2, 某文件的后缀是 cs,...错误打Ⅹ) 判断题 正确打 2 ( ( ( ( )1>一个解决方案可以由 C#项目和 ...
热门文档