|
传奇3大补帖辅助1.76版Delphi开源代码
unit Hook;
interface
uses Windows, Messages, Dialogs, Sysutils, PopWin;
var
hNextHookProc: HHook;
procSaveExit: Pointer;
function sethook: bool; export;
function hookproc(iCode: Integer; wParam: WPARAM; lParam: LPARAM):
LRESULT; stdcall;
function endhook: bool; export;
procedure HotKeyHookExit; far;
implementation
function HookProc(iCode: integer; wParam: wParam; lParam: lParam):
LResult; stdcall;
var
hwnd: dword;
AppRect: TRect;
title: pchar;
begin
result := 0;
title := '';
if iCode < 0 then
begin
CallNextHookEx(hnexthookproc, iCode, wParam, lParam);
result := 0;
Exit;
end;
if ((lParam and $80000000) = 0) and (wParam = $6A) then
begin
hwnd := getforegroundwindow;
try
GetMem(title, 255);
getwindowtext(hwnd, title, 255);
if title = 'Legend Of Mir 3' then
begin
try
Messagebeep(0);
FrmPopWin := TFrmPopWin.CreateParented(hwnd);
GetWindowRect(hwnd, AppRect);
FrmPopWin.Caption := title + ' 酷酷神仙制作';
FrmPopWin.Show;
finally
//FrmPopWin.Free;
end;
end;
finally
FreeMem(title);
end;
result := 1;
end;
end;
function sethook: bool; export;
begin
result := false;
if hnexthookproc <> 0 then
exit;
hNextHookProc := SetWindowsHookEx(WH_KEYBOARD, hookproc, HInstance, 0);
Result := hNextHookProc <> 0;
end;
procedure hotkeyhookexit;
begin
if hNextHookProc <> 0 then
endHook;
ExitProc := procSaveExit;
end;
function endhook: bool; export;
begin
if hNextHookProc <> 0 then
begin
UnhookWindowshookEx(hNextHookProc); // 解除 Keyboard Hook
hNextHookProc := 0;
end;
Result := hNextHookProc = 0;
end;
end.
|
|