I have not implemented anything in PB. My original implementation is in Delphi 3.
I want to implement in PB but the mechanism that is implemented is using memory mapped files to map into target applications memory space.
The code is Delphi is something like this:
procedure TForm1.FormCreate(Sender: TObject);
begin
sharedFileHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, 256, 'YogiSharedFile');
sharedData := MapViewOfFile(sharedFileHandle, FILE_MAP_WRITE, 0, 0, 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnmapViewOfFile(sharedData);
CloseHandle(sharedFileHandle);
end;
// --------- This routine is executed (called) when ever user presses a key in any windows based apps
procedure TForm1.main(var msg: TMessage);
begin
msg.Result := 0; // the dll should not touch this keypress
LabelHandle.Caption := IntToStr(sharedData[0]); // handle of the current window
GHwnd := sharedData[0];
if char(msg.wParam) = 'Q' then begin
msg.Result := 1; // tell the dll to kill the original keypress
// *** THIS IS LINE IS REQUIRED TO
// *** REMAP ONLY KEYDOWNS
// *** THE MEAINING OF THE BITS CAN
// *** BE FOUND IN THE WIN32SDK HELP
// *** UNDER KEYWORD: "KeyboardProc"
if (msg.LParam and $80000000) = 0 then
PostMessage(sharedData[0], WM_CHAR, ord('*'), 1);
end;
if char(msg.wParam) = 'Z' then begin
msg.Result := 1; // tell the dll to kill the original keypress
//Delete previously typed character and insert another one
if (msg.LParam and $80000000) = 0 then begin
SendMessage(GHwnd, WM_KEYDOWN, VK_BACK, 0);
PostMessage(GHwnd, WM_CHAR, VK_BACK, 1);
SendMessage(sharedData[0], WM_KEYDOWN, $1FFF0001, 0);
PostMessage(sharedData[0], WM_CHAR, ord('M'), 1);
end;
end;
If you observe the code the implemeted Hook passes all the messages regarding keyboard to the delphi form. How can such a thing be possible in case of PB where forms are created in a way that I am not aware of.
