|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
//DLL代码如下:
library MouseHOOK;
uses
Windows, Messages;
var
hNextHookProc: HHook;
//↓核心代码段↓
function KeyboardHookHandler(iCode: Integer;wParam: WPARAM;lParam: LPARAM): LRESULT; stdcall; export;
const
_KeyPressMask = $80000000;
var
p:TPoint;
begin
If iCode < 0 Then
begin
Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);
Exit;
end;
if ((lParam and _KeyPressMask) <> 0) and (wParam =120)then
begin
Mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); <----问题在这,希望能实现按下F9的时候,控制鼠标左键按下,在桌面操作没发现问题,当打开一个文件夹,然后点关闭按钮的时候,卡在按下的操作里面,无法关闭文件夹---->
<----求大神给点意见,怎么解决这个实现键盘操作鼠标---->
end;
if ((lParam and _KeyPressMask) = 0) and ////F9键值
(wParam =120)then
begin
Mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//模拟鼠标按下左键后松开
end;
if ((lParam and _KeyPressMask) <> 0) and (wParam =121)then
begin
Mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
end;
if ((lParam and _KeyPressMask) = 0) and (wParam =121)then
begin
Mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);//模拟鼠标按下右键
end;
end;
function DisableMouse: BOOL; export;
begin
Result := False;
if hNextHookProc <> 0 then Exit;
hNextHookProc := SetWindowsHookEx(WH_MOUSE,MouseHookProc,HInstance,0);
Result:=False;
end;
function EnableMouse: BOOL; export;
begin
if hNextHookProc <> 0 then
begin
UnhookWindowshookEx(hNextHookProc);
hNextHookProc := 0;
end;
Result := hNextHookProc = 0;
end;
exports
EnableMouse,
DisableMouse;
end.
|
|