
21.04.2015, 12:12
|
Прохожий
|
|
Регистрация: 17.04.2015
Сообщения: 7
Версия Delphi: Delphi 7
Репутация: 10
|
|
Зацикливание поборол :-). Все как бы работает, но...
Меняю левую на среднюю, среднюю на леву. При нажатии на левую она работает как левая+средняя, а при нажатии на среднюю - средняя+левая.
То есть система не полностью мной контролируется...
Мож в другом месте чета напортачил?...
Код:
function JournalProc(Code, wParam: Integer; var EventStrut: TEventMsg): Integer; stdcall;
var
Pt: TPoint;
begin
Result := CallNextHookEx(JHook, Code, wParam, Longint(@EventStrut));
if Code < 0 then Exit;
if Code = HC_SYSMODALON then Exit;
if Code = HC_ACTION then
begin
//===============================================WM_LBUTTON==========================
if (EventStrut.message = WM_LBUTTONDOWN) then
begin
GetCursorPos(Pt);
case MouseKey[1] of
2:begin
if ll=0 then
begin
EventStrut.message:=WM_NULL;
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MIDDLEDOWN, Pt.x, Pt.y, 0, 0);
ll:=1;
exit;
end else
begin
EventStrut.message:=WM_NULL;
ll:=0;
exit;
end;
end;
end;//case
end;
if (EventStrut.message = WM_LBUTTONUP) then
begin
GetCursorPos(Pt);
case MouseKey[1] of
2:begin
if rr=0 then
begin
EventStrut.message:=WM_NULL;
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_MIDDLEUP, Pt.x, Pt.y, 0, 0);
rr:=1;
exit;
end else
begin
EventStrut.message:=WM_NULL;
rr:=0;
exit;
end;
end;
end;//case
end;
//======================================WM_MBUTTO===============================================================
if (EventStrut.message = WM_MBUTTONDOWN) then
begin
GetCursorPos(Pt);
case MouseKey[2] of
1:begin
if ll=0 then
begin
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, Pt.x, Pt.y, 0, 0);
ll:=1;
exit;
end else
begin
EventStrut.message:=WM_NULL;
ll:=0;
exit;
end;
end;
end;//case
end;
if (EventStrut.message = WM_MBUTTONUP) then
begin
GetCursorPos(Pt);
case MouseKey[2] of
1:begin
if rr=0 then
begin
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, Pt.x, Pt.y, 0, 0);
rr:=1;
exit;
end else
begin
EventStrut.message:=WM_NULL;
rr:=0;
exit;
end;
end;
end;//case
end;
end;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
Handled := False;
if (Msg.message = WM_CANCELJOURNAL) and FHookStarted then
JHook := SetWindowsHookEx(WH_JOURNALRECORD, @JournalProc, 0, 0);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
MyMouse: TPoint;
begin
if FHookStarted then
begin
ShowMessage('Mouse is already being Journaled, can not restart');//Mouse is already being Journaled, can not restart');
Exit;
end;
JHook := SetWindowsHookEx(WH_JOURNALRECORD, @JournalProc, hInstance, 0);
{SetWindowsHookEx starts the Hook}
if JHook > 0 then
begin
FHookStarted := True;
end
else
ShowMessage('No Journal Hook availible');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if FHookStarted then
UnhookWindowsHookEx(JHook);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
FHookStarted := False;
UnhookWindowsHookEx(JHook);
JHook := 0;
end;
|