如何向一个窗口里的输入框自动填入信息?

解决方案 »

  1.   

    Edit1.Text := '自动要填的内容'
      

  2.   

    luke5678(奇异) 晕,程序是别人的,不可以修改我的意思是说如何用程序A向程序B的输入框中填入信息?
      

  3.   

    -_-#明白你的意识了...thinking...
      

  4.   

    var
      Form1: TForm1;
      cnt : Integer = 0;
      function EnumWindowsProc(Hwnd:THandle;lParam:LParam):boolean;Stdcall;
      function EnumChildProc(Hwnd:THandle;lParam:LParam):boolean;Stdcall;implementation{$R *.DFM}function EnumWindowsProc(Hwnd:THandle;lParam:LParam):boolean;
    var
      WindowCaption:array[0..254] of Char;
    begin
      GetWindowText(Hwnd,WindowCaption,255);
      if StrPas(WindowCaption)=Form1.Edit1.Text then
      begin
        cnt := 0;
        EnumChildWindows(Hwnd,@EnumChildProc,0);
        Result := False;
        Exit;
      end;
      Result := True;
    end;function EnumChildProc(Hwnd:THandle;lParam:LParam):boolean;
    var
      WindowCaption,WindowClass:array[0..254] of Char;
    begin
      GetClassName(Hwnd,WindowClass,255);
      if Pos('EDIT',UpperCase(StrPas(WindowClass))) > 0 then
      begin
        Inc(cnt);
        SendMessage(Hwnd,WM_SETTEXT,0,LongInt(PChar(IntToStr(cnt))));
        ////此处换成SendMessage(Hwnd,WM_SETTEXT,0,LongInt(PChar('你想送的字符串')));即可
      end;
      Result := True;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Enumwindows(@EnumWindowsProc,0);
    end;
      

  5.   

    也可以这样,不同的只是查找这个EDIT句柄,发送都是一样的方法:
    var
      h,e:HWND;begin
      h:=FindWindow(nil,'TForm1');
      e:=FindWindowEx(h,0,'TEdit',nil);
       SendMessage(e,WM_SETTEXT,0,LongInt(PChar(IntToStr(cnt))));
        ////此处换成SendMessage(e,WM_SETTEXT,0,LongInt(PChar('你想送的字符串')));
    end;