SendMessage(Wnd,WM_KEYDOWN, VK_HOME, 0);
  ASC:=ORD('F');
  SendMessage(Wnd,WM_CHAR,ASC,0);

解决方案 »

  1.   

    PostMessage(self.Handle, WM_KEYDOWN, VK_Tab, 0);
      

  2.   

    对用SendMessage或Perform都可以!!自己查帮助!!!
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);begin
    with RichEdit1 do
      Begin
        SelStart := StrToInt(MaskEdit1.Text);
        RichEdit1.Perform(EM_SCROLLCARET, 0, 0);
      end;
    end;
      

  4.   

    向EDIT控件中发个A字符:
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      edit1.Perform(WM_Char,Ord('A'),0);
    end;
      

  5.   

    //向一个WinControl发送按键或字符
    procedure SendTextToWinControl(const WinControlHandle: HWND; const str: string);
    var
      i: integer;
    begin
      if WinControlHandle = 0 then
        Exit;
      if Length(str) = 0 then
        Exit;
      for i:= 1 to Length(str) do
      begin
        if Ord(str[i]) in [9, 13, 32..254] then
          SendMessage(WinControlHandle, WM_CHAR, Ord(str[i]), 0);
      end;
    end;
    调用此过程就可
      

  6.   

    谢谢大家:)
    不好意思,我问题是如何向一正在运行的运用程序发送消息,比如A.exe发送<Ctrl + p>给正在运行的B.exe,A的代码应该如何写,谢谢
      

  7.   

    Syntax
    keybd_event(
    bVk: Byte; {virtual-key code}
    bScan: Byte; {scan-code}
    dwFlags: DWORD; {option flags}
    dwExtraInfo: DWORD {additional information about the key}
    ); {this procedure does not return a value}Description
    The keybd_event function simulates a keystroke. The system generates a WM_KEYUP or WM_KEYDOWN message as if the key were pressed on the keyboard.example:
    procedure TForm1.ButtonSnapShotClick(Sender: TObject);
    var
      Bitmap: TBitmap;     // holds a bitmap
    begin
      {see which radio button is checked}
      if ImageOptions.ItemIndex = 0
      then keybd_event(VK_SNAPSHOT,1,0,0)    {desktop window snapshot}
      else keybd_event(VK_SNAPSHOT,0,0,0);   {client window snapshot}  {check to see if there is a picture}
      if Clipboard.HasFormat(CF_BITMAP) then  begin
        {Create a bitmap to hold the contents of the Clipboard}
        Bitmap := TBitmap.Create;    {trap for clipboard bitmap errors}
        try
          {get the bitmap off the clipboard using Assign}
          Bitmap.Assign(Clipboard);      {copy the bitmap to the Image}
          Image1.Canvas.Draw(0, 0, Bitmap);
        finally
          {the bitmap is no longer needed, so free it}      Bitmap.Free;
        end;
      end;
    end;