Witam. Chcialbym zeby po odpaleniu danej aplikacji komponent KeySpyXP "obudzil sie" i zaczal zapisywac klawisze przez 10 sekund, a nastepnie wylaczal sie. Obecnie uzywam nastepujacego kodu:
implementation
{$R *.dfm}
function CheckProcess(Name: String): Boolean;
function ProcessList: TStringList;
var
Handle: THandle;
Process: TProcessEntry32;
begin
Handle:=CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
Process.dwSize:=SizeOf(Process);
Result:=TStringList.Create;
if Integer(Process32First(Handle, Process)) <> 0 then
repeat
Result.Append(Process.szExeFile);
until Integer(Process32Next(Handle, Process)) = 0;
CloseHandle(Handle);
end;
var
i: Integer;
ProcessL: TStringList;
begin
ProcessL := TStringList.Create;
ProcessL := ProcessList;
for i := 0 to ProcessL.Count-1 do
if LowerCase(ProcessL[i]) = LowerCase(Name) then
begin
Result := True;
Break;
end
else
Result := False;
end;
//
procedure TForm1.Timer3Timer(Sender: TObject);
begin
if CheckProcess('nazwa_procesu.exe') then
begin
keyspyxp1.enabled:=true;
end
else
begin
keyspyxp1.enabled:=false;
end;
end; //W tym timerze nastawilem 10000 ms.
Przy kompilacji nie występują zadne bledy lecz gdy napisze w procesie nazwa_procesu.exe zalozmy: 123456 / fohrman to na memo zamiast tego wystepuje takie cos: 1346 / fhman (roznie, po prostu nie lapie wszystkich klawiszy). Jak ten problem rozwiazac? A moze inny kod? Thx ;].