library
PasteHook;
uses
Windows, Messages, ActnPopup,clipbrd, Menus, SysUtils, dialogs;
{$R *.res}
type
blank =
class
procedure
OnPopClick(Sender: TObject);
constructor
Create;
destructor
Destroy; override;
end
;
var
SysHook : HHook =
0
;
State:
Boolean
=
False
;
PasteMenu: TPopUPMenu;
Blank1: Blank;
HW: HWND;
procedure
Blank
.
OnPopClick(Sender: TObject);
var
str:
string
;
begin
str:=copy((Sender
as
Tmenuitem).Caption,
2
,
255
);
Clipboard
.
asText:=str;
SendMessage(HW,WM_PAste,
0
,
0
);
HW:=
0
;
end
;
constructor
blank
.
Create;
begin
end
;
destructor
Blank
.
Destroy;
begin
inherited
;
end
;
Function
FilterFunc(Code:
integer
; wParam, lParam:DWORD):DWORD; stdcall;
var
MousePos:TPoint;
begin
if
code = HC_ACTION
then
begin
if
(wParam =
112
)
and
((GetKeyState(VK_Control)
and
32768
) =
32768
)
then
begin
HW:= GetFocus;
GetCursorPos(MousePos);
PasteMenu
.
Popup(MousePos
.
X,Mousepos
.
Y);
Result:=CallNextHookEx(SysHook, Code, wParam, lParam);
end
;
end
else
begin
Result:=CallNextHookEx(SysHook, Code, wParam, lParam);
end
;
end
;
procedure
AccHook();
begin
if
State =
False
then
begin
SysHook := SetWindowsHookEx(WH_KeyBoard,@FilterFunc, HInstance,
0
);
State:=
True
;
Blank1:= Blank
.
Create;
PasteMenu:= TPopUpMEnu
.
Create(
nil
);
PasteMenu
.
Items
.
Add(NewItem(
'123'
,
0
,
False
,
True
, Blank1
.
OnPopClick,
0
,
'name'
));
end
else
begin
UnhookWindowsHookEx(SysHook) ;
Blank1
.
Destroy;
SysHook :=
0
;
State :=
False
;
end
;
end
;
exports
AccHook index
1
;
begin
end
.