Hi folks,
I am developing an application that captures Keyboard keys pressed and mouse actions and display them on the screen ... For this, i have two hooks (WM_KEYBOARD and WM_MOUSE), each one in its own DLL (MouseHook.dll and KeyHook.dll).
MouseHook has the following procedure:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure OnMouseEvent(Sender: TObject; AMouseStates: TMouseStates);
procedure TForm1.OnMouseEvent(Sender: TObject; AMouseStates: TMouseStates); begin if ((AMouseStates.ButtonInfo = WM_LBUTTONDOWN)) then begin Label1.Caption := 'Left Mouse Button pressed'; end; end; |
KeyHook has the following procedure:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure OnKeyPressed(Sender: TObject; AKeyStates: TKeyStates; AKeyNames: TKeyNames);
procedure TForm1.OnKeyPressed(Sender: TObject; AKeyStates: TKeyStates; AKeyNames: TKeyNames); begin if AKeyStates.KeyDown then begin Label1.Caption := 'Key Pressed'; end; end; |
I need change the Label1.Caption to "Key Pressed and Left Mouse Button pressed" when the user press a key and the left mouse button simultaneously.
So, i am trying change the line "if AKeyStates.KeyDown then" (inside the OnKeyPressed procedure) to something like this:
KeyHook has the following procedure:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure OnKeyPressed(Sender: TObject; AKeyStates: TKeyStates; AKeyNames: TKeyNames);
procedure TForm1.OnKeyPressed(Sender: TObject; AKeyStates: TKeyStates; AKeyNames: TKeyNames); begin if (AKeyStates.KeyDown) and (AMouseStates.ButtonInfo = WM_LBUTTONDOWN) then begin Label1.Caption := 'Key Pressed and Left Mouse Button pressed'; end; end; |
But, when i changed that line, Delphi says: "Undeclared identifier: 'AMouseStates' ...
What´s wrong with my code?
Any help or comments will be deeply appreciated.
Best regards and happy new year...
JOEL RODRIGUES
Moderiert von
Gausi: Delphi-Tags hinzugefügt