Registriert seit: 12. Okt 2016
235 Beiträge
Delphi 10 Seattle Professional
|
AW: Sendkeys, "Enter" einbauen
31. Jan 2017, 08:21
Code:
{$POINTERMATH ON}
procedure TForm1.SendKeys(const S: String);
var
InputEvents: PInput;
I, J: Integer;
begin
if S = '' then
begin
if Checkbox1.checked=True then
begin
Keybd_Event(VK_RETURN,0,0,0); //Taste drücken
Keybd_Event(VK_RETURN,0,KEYEVENTF_KEYUP,0); //Taste loslassen
end;
Exit;
end;
GetMem(InputEvents, SizeOf(TInput) * (Length(S) * 2));
try
J := 0;
for I := 1 to Length(S) do
begin
InputEvents[J].Itype := INPUT_KEYBOARD;
InputEvents[J].ki.wVk := 0;
InputEvents[J].ki.wScan := Ord(S[I]);
InputEvents[J].ki.dwFlags := KEYEVENTF_UNICODE;
InputEvents[J].ki.time := 0;
InputEvents[J].ki.dwExtraInfo := 0;
Inc(J);
InputEvents[J].Itype := INPUT_KEYBOARD;
InputEvents[J].ki.wVk := 0;
InputEvents[J].ki.wScan := Ord(S[I]);
InputEvents[J].ki.dwFlags := KEYEVENTF_UNICODE or KEYEVENTF_KEYUP;
InputEvents[J].ki.time := 0;
InputEvents[J].ki.dwExtraInfo := 0;
Inc(J);
end;
SendInput(J, InputEvents[0], SizeOf(TInput));
finally
FreeMem(InputEvents);
end;
end;
Habe es hiermit probier, allerdings macht er immernoch kein Enter:/
|
|
Zitat
|