mousehookdemou.pas
来自「Delphi Win32核心API参考光盘源码 本书包含了常用的Windows」· PAS 代码 · 共 54 行
PAS
54 行
unit MouseHookDemoU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function SetHook: Boolean; stdcall;
function RemoveHook: Boolean; stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
function SetHook; external 'GMouseHook.dll' name 'SetHook';
function RemoveHook; external 'GMouseHook.dll' name 'RemoveHook';
procedure TForm1.Button1Click(Sender: TObject);
begin
{set the hook}
if SetHook then
ShowMessage('Global Mouse Hook Set, Click on Desktop')
else
ShowMessage('Global Mouse Hook Not Set');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{remove the hook}
if RemoveHook then
ShowMessage('Global Mouse Hook Removed, Click on Desktop')
else
ShowMessage('Global Mouse Hook Not Removed');
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?