嗯...老生常谈的话题, 不过系统的总结了一下, 找了个相对简单的实现方式, 可以方便的发送任何文字
参考另一片文章: http://www.cnblogs.com/-clq/archive/2011/10/01/2197047.html
直接贴代码:
var
nInputs: array[0..1] of tagINPUT;
nData: WideChar;
nStr: WideString;
i: Integer;
begin
nStr := '测试内容123';
for I := 1 to Length(nStr) do
begin
nData := nStr[i];
with nInputs[0] do
begin
Itype := INPUT_KEYBOARD;
ki.wVk := 0;
ki.wScan := Word(nData);
ki.dwFlags := KEYEVENTF_UNICODE;
end;
SendInput(1, nInputs[0], SizeOf(nInputs[0]));
with nInputs[1] do
begin
Itype := INPUT_KEYBOARD;
ki.wVk := 0;
ki.wScan := Word(nData);
ki.dwFlags := KEYEVENTF_KEYUP or KEYEVENTF_UNICODE;
end;
SendInput(1, nInputs[1], SizeOf(nInputs[1]));
end;
end;
http://www.cnblogs.com/hs-kill/p/4761297.html