1
procedure SendText(ds:string);
var
  TI: TInput;
  KI: TKeybdInput;
  i: integer;
begin
  TI.Itype := INPUT_KEYBOARD;
  for i := 1 to Length(ds) do
  begin
    KI.wVk := Ord(UpCase(ds[i]));
    KI.dwFlags := 0;
    TI.ki := KI;
    SendInput(1, TI, SizeOf(TI));
    KI.dwFlags := KEYEVENTF_KEYUP;
    TI.ki := KI;
    SendInput(1, TI, SizeOf(TI));
  end;
end;

如何添加 Unicode?关于如何使用复制俄语(西里尔语)符号的任何建议SendInput(Edit1.Text);

4

2 回答 2

7

在此示例中,我使用了JEDI 项目中的单元JclUnicode.pas。如果您有 Delphi 6,那么您可以在 uses 子句中省略 JclUnicode。

uses
  JclUnicode;

procedure SendText(const Value: WideString);
var
  I: Integer;
  S: WideString;
  TI: TInput;
  KI: TKeybdInput;
const
  KEYEVENTF_UNICODE = $0004;
begin
  S := WideUpperCase(Value); 
  TI.Itype := INPUT_KEYBOARD;
  for I := 1 to Length(S) do
  begin
    KI.wVk := 0;
    KI.dwFlags := KEYEVENTF_UNICODE;
    KI.wScan := Ord(S[I]);
    TI.ki := KI;
    SendInput(1, TI, SizeOf(TI));
  end;
end;
于 2011-10-18T10:03:56.757 回答
0
uses
  JclUnicode;

procedure SendText(const Value: WideString);
var
  I: Integer;
  S: WideString;
  TI: TInput;
  KI: TKeybdInput;
const
  KEYEVENTF_UNICODE = $0004;
begin
  S := WideUpperCase(Value); 
  TI.Itype := INPUT_KEYBOARD;
  for I := 1 to Length(S) do
  begin
    KI.wVk := 0;
    KI.dwFlags := KEYEVENTF_UNICODE;
    KI.wScan := Ord(S[I]);
    TI.ki := KI;
    SendInput(1, TI, SizeOf(TI));

    // release keys to avoid double key missing (like P in UPPER)
    KI.dwFlags := KEYEVENTF_KEYUP;
    TI.ki := KI;
    SendInput(1, @TI, SizeOf(TI));     
  end;
end;
于 2019-04-06T16:12:11.383 回答