zoukankan      html  css  js  c++  java
  • delphi hook alt+F4 ctrl+delete+alt win键等

    delphi hook alt+F4 ctrl+delete+alt win键等
    unit uHook;
    
    
    interface
    
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, Dialogs,
      StdCtrls;
    
    
    type
      tagKBDLLHOOKSTRUCT = packed record
        vkCode: DWORD;
        scanCode: DWORD;
        flags: DWORD;
        time: DWORD;
        dwExtraInfo: DWORD;
      end;
    
    
      KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
    
    
      PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
    
    
    const
      WH_KEYBOARD_LL = 13;
    
    
    const
      LLKHF_ALTDOWN = $20;
    
    
    function LowLevelKeyboardProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;
    
    
    procedure hookstar;
    
    
    procedure hookend;
    
    
    var
      hhkLowLevelKybd: HHOOK;
    
    
    implementation
    
    
    function LowLevelKeyboardProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;
    var
      fEatKeystroke: BOOL;
      p: PKBDLLHOOKSTRUCT;
    begin
      Result := 0;
      fEatKeystroke := FALSE;
      p := PKBDLLHOOKSTRUCT(lParam);
      if (nCode = HC_ACTION) then
      begin
        case wParam of
              WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP:fEatKeystroke:=
    //    ((p.vkCode=VK_TAB) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
    //    ((p.vkCode=VK_ESCAPE) and ((p.flags and LLKHF_ALTDOWN) <> 0))or
    //    (p.vkCode=VK_Lwin) or
    //    (p.vkCode=VK_Rwin) or
    //    (p.vkCode=VK_apps) or
    //    ((p.vkCode=VK_ESCAPE) and ((GetKeyState(VK_CONTROL) and $8000) <> 0)) or
        ((p.vkCode=VK_F4) and ((p.flags and LLKHF_ALTDOWN) <> 0))
    //    or
    //    ((p.vkCode=VK_SPACE) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
    //    (((p.vkCode=VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN and p.flags) and (P.vkCode=VK_Delete)))
        end;
      end;
      if fEatKeystroke = True then
        Result := 1;
      if nCode <> 0 then
        Result := CallNextHookEx(0, nCode, wParam, lParam);
    end;
    
    
    procedure HookStar;
    begin
      if hhkLowLevelKybd = 0 then
        hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL, LowLevelKeyboardProc, Hinstance, 0);
    end;
    
    
    procedure HookEnd;
    begin
      if (hhkLowLevelKybd <> 0) and UnhookWindowsHookEx(hhkLowLevelKybd) then
        hhkLowLevelKybd := 0;
    end;
    
    
    initialization
      hookstar;
    
    
    finalization
      hookend;
    
    
    end.
  • 相关阅读:
    VUE3 使用 Ant Design Vue 图标库的图标
    Vue3 前端获取数据后 “响应式表示” ref and reactive
    Vue3 使用 生命周期函数
    SpringBoot 前后端分离 跨域小问题
    Vue 使用 Ant Design Vue 。
    SB + Mybatis generator 实现模糊查询 且 过滤数据返回体 + Bean转换
    springboot+mybatis 利用插件生成代码
    spark-sql-03从mysql获取数据上传数据
    spark-sql-02
    sprak-sql-01-基础
  • 原文地址:https://www.cnblogs.com/blogpro/p/11454055.html
Copyright © 2011-2022 走看看