procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hCurrentWindow,hWnd1:HWnd;<br> szText:array[0..254]of char;<br> Wind : String;<br>begin<br> hCurrentWindow:=GetWindow(Handle,GW_HWNDFIRST);<br> While hCurrentWindow<>0 Do<br> Begin<br> If GetWindowText(hCurrentWindow,@szText,255)<>0 then<br> if pos('无标题 - 记事本',Strpas(@szText))<>0 then begin<br> hWnd1 := GetWindow(hCurrentWindow,GW_Child);;<br><br> SetForegroundWindow(hWnd1);<br> keybd_event(VK_MENU , MapVirtualKey(VK_MENU , 0 ), 0 , 0 );<br> sleep(100);<br> keybd_event(Ord('F'), MapVirtualKey(Ord('F'), 0 ), 0 , 0 );<br> keybd_event(VK_MENU , MapVirtualKey(VK_MENU ,0),KEYEVENTF_KEYUP, 0);<br> keybd_event(Ord('F'), MapVirtualKey(Ord('F'),0),KEYEVENTF_KEYUP, 0);<br> sleep(200);<br> exit;<br> end;<br> hCurrentWindow:=GetWindow(hCurrentWindow,GW_HWNDNEXT);<br> end;<br> hCurrentWindow:=GetWindow(Handle,GW_HWNDFIRST);<br> end;<br><br>凑个数,以前写得东西<br><br>我只能做到先激活再发消息<br><br>大侠见笑了