如何在我的应用程序中捕获任何鼠标点击
How to catch any mouseclick in my application
在 Delphi 10 中获得我的 (windows-) 应用程序中每次鼠标点击的最佳方法是什么?
我实际上想实现触摸声音,但 OnGesture
仅 return 手势(惊喜),所以我想进行任何点击。我不想捕获每个 VCL OnClick
,我希望得到一个整体 hook/trigger/event
@David Heffernan说的对,可以使用消息事件
如果你想在其他应用程序中获取所有事件,你应该使用钩子。
这是通过 message(WM_LBUTTONDOWN
WM_LBUTTONUP
)
实现的功能
覆盖application.OnMessage
application.OnMessage := yourOnMessage
覆盖 WndProc(var message:TMessage);
procedure TForm1.WndProc(var message: TMessage);
begin
inherited;
if message.Msg = WM_LBUTTONDOWN then
ShowMessage('down');
end;
只听WM_LBUTTONDOWN
procedure Wmme(var message:TMessage);message WM_LBUTTONDOWN;
procedure TForm1.WndProc(var message: TMessage);
begin
inherited;
if message.Msg = WM_LBUTTONDOWN then
ShowMessage('down');
end;
在 Delphi 10 中获得我的 (windows-) 应用程序中每次鼠标点击的最佳方法是什么?
我实际上想实现触摸声音,但 OnGesture
仅 return 手势(惊喜),所以我想进行任何点击。我不想捕获每个 VCL OnClick
,我希望得到一个整体 hook/trigger/event
@David Heffernan说的对,可以使用消息事件
如果你想在其他应用程序中获取所有事件,你应该使用钩子。
这是通过 message(WM_LBUTTONDOWN
WM_LBUTTONUP
)
实现的功能
覆盖application.OnMessage
application.OnMessage := yourOnMessage
覆盖 WndProc(var message:TMessage);
procedure TForm1.WndProc(var message: TMessage);
begin
inherited;
if message.Msg = WM_LBUTTONDOWN then
ShowMessage('down');
end;
只听WM_LBUTTONDOWN
procedure Wmme(var message:TMessage);message WM_LBUTTONDOWN;
procedure TForm1.WndProc(var message: TMessage);
begin
inherited;
if message.Msg = WM_LBUTTONDOWN then
ShowMessage('down');
end;