首先你要得到目的的handle,就能发消息了。。
给个函数做参考
procedure SendKeys(keys:string);
var CharCode,i:integer;
Sstr:string;
hFocus,hWindow:HWND;
ThreadIDWord;
begin
hWindow:=GetForegroundWindow;
ThreadID:=GetWindowThreadProcessId(hWindow,nil);
AttachThreadInput(GetCurrentThreadId,ThreadID,true);
hFocus:=GetFocus;
AttachThreadInput(GetCurrentThreadId,ThreadID,false);
if hFocus<>0 then begin
for i:=1 to Length(keys) do begin
Sstr:=keys;
CharCode:=ord(Sstr[1]);
SendMessage (hFocus,WM_IME_CHAR,CharCode,1);
end;
end;
end;
至于开始按钮,你也可以找到handle后在做处理
FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0,'Button',nil)就是了