嘻嘻,把以前cAkk的单元改一下就可以实现。在你的单元里 uses unit2……
可以发送字符,然后模拟回车
unit Unit2;
interface
uses windows,messages;
procedure SendKeys(sSend:string);
implementation
procedure SendKeys(sSend:string);
var
i:integer;
focushld,windowhld:hwnd;
threadld:dword;
ch: byte;
begin
windowhld:=GetForegroundWindow;
threadld:=GetWindowThreadProcessId(Windowhld,nil);
AttachThreadInput(GetCurrentThreadId,threadld,true);
Focushld:=getfocus;
AttachThreadInput(GetCurrentThreadId,threadld,false);
if focushld = 0 then Exit;
i := 1;
while i <= Length(sSend) do
begin
ch := byte(sSend);
if Windows.IsDBCSLeadByte(ch) then
begin
Inc(i);
SendMessage(focushld, WM_IME_CHAR, MakeWord(byte(sSend), ch), 0);
end
else
SendMessage(focushld, WM_IME_CHAR, word(ch), 0);
Inc(i);
end;
postmessage(focushld,WM_keydown,13,0);
end;
end.