DirectInput 没研究过..
procedure TMainForm.Button2Click(Sender: TObject);
var
wnd: Hwnd;
s: string;
i: integer;
begin
WinExec('notepad.exe',SW_SHOW);
wnd := FindWindow('notepad', nil);
if wnd<>0 then
begin
wnd := FindWindowEx(wnd,0,'Edit',nil);
s := 'hello, world.';
for i := 1 to length(s) do
SendMessage(wnd, WM_CHAR, ord(s), 0);
end
else ShowMessage('notepad not find');
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0);
keybd_event(ord('S'), MapVirtualKey(ord('S'), 0), 0, 0);
keybd_event(ord('S'), MapVirtualKey(ord('S'), 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0);
wnd := FindWindow('#32770', nil);
if wnd<>0 then
begin
keybd_event(ord('S'), MapVirtualKey(ord('S'), 0), 0, 0);
keybd_event(ord('S'), MapVirtualKey(ord('S'), 0), KEYEVENTF_KEYUP, 0);
keybd_event(13, MapVirtualKey(13, 0), 0, 0);
keybd_event(13, MapVirtualKey(13, 0), KEYEVENTF_KEYUP, 0);
end
else ShowMessage('Save Dialog not found');
end;