⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uhookcode.pas

📁 Delphi编写的Cs1.6中文输入软件 支持CS游戏全屏下的中文输入;但只支持CS1.6
💻 PAS
字号:
unit UHookCode;

interface

uses windows, QStrings, Classes, Sysutils{, UShowWin};

function HookOn:Boolean;stdcall;
procedure HookOff;stdcall;

implementation

uses Controls, StdCtrls, Messages, UKeyInput;

var
  HookH:HHook;    //钩子句柄
  ifOpen:Boolean;
  iH:Integer;

procedure GetCSHandle;
begin
  iH:=FindWindow(nil,'Counter-Strike');
  if iH=0 then iH:=FindWindow(nil,'strike');
  if iH=0 then iH:=FindWindow(nil,'HL');
  if iH=0 then iH:=FindWindow(nil,'Condition Zero');
  if iH=0 then iH:=FindWindow('Valve001',nil);
end;

procedure ShowInput;

begin
  if frmKeyInput=nil then
     frmKeyInput:=TfrmKeyInput.Create(nil)
  else frmKeyInput.Show;
end;

function keyhook(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
  if ifOpen then
  begin
    Result:=CallNextHookEx(HookH,code,Wparam,lParam);
    Exit;
  end;
  Result:=1;
  ifOpen:=True;
  if (code=HC_ACTION) and (wParam=123) then  ShowInput;
  Result:=CallNextHookEx(HookH,code,Wparam,lParam);
  ifOpen:=False;
end;

function HookOn:Boolean;
var
  iP:Cardinal;
begin
  GetCSHandle;
  iP:=GetWindowThreadProcessId(iH,nil);
  HooKH:=SetWindowsHookEx(WH_KEYBOARD,keyHook,HInstance,iP);
  Result:=HookH<>0;
  ifOpen:=False;
end;

procedure HookOff;
begin
  UnHookWindowsHookEx(HookH);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -