⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 写窗口控件文本写窗口控件文本写窗口控件文本
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  hPar:thandle; 
  hcl,hc12:array[1..100] of thandle; 
  i:cardinal; 
implementation

function EnumChildProc( handle:thandle; lParam:integer):boolean;stdcall; 
begin
  if handle <>0 then
  begin
    hcl[i]:=handle;
    i:=i+1;
    Result:=true;
  end
  else
    Result:=false; 
end;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var 
  n:cardinal;
  text,tempstr,temp:string;
  buf:array[0..99] of char;
  Old:array[0..99] of char;
begin
  i:=1;
  fillchar(buf,100,0);
  text:=Edit1.Text;
  temp:='a';
  hpar:=Findwindow(nil,'计算器');
  if hpar=0 then
  begin
    showmessage('没有发现目标!');
    exit;
  end;
  EnumChildWindows(hpar,@EnumChildProc,0);
  for n:= 1 to 4 do
  begin
    if hcl[n] <>0 then
    begin
      getclassname(hcl[n],buf,100);
      if buf='WindowsForms10.EDIT.app.0.378734a' then
        hc12[n]:=hcl[n]
    end;
  end;
  for n := 1 to 4 do
  begin
    if (hc12[n] <>0) then
    begin
      fillchar(Old,sizeof(Old),0);
      sendmessage(hc12[n],wm_gettext,sizeof(Old),integer(@Old));
      tempstr := Old;
      if tempstr='1' then
      begin
        temp:='a';
        sendmessage(hc12[n],wm_settext,0,integer(temp))
      end else
      if tempstr='2' then
      begin
        temp:='b';
        sendmessage(hc12[n],wm_settext,0,integer(temp))
      end else
      if tempstr='3' then
      begin
        temp:='c';
        sendmessage(hc12[n],wm_settext,0,integer(temp))
      end else
      if tempstr='4' then
      begin
        temp:='d';
        sendmessage(hc12[n],wm_settext,0,integer(temp))
      end else
        sendmessage(hc12[n],wm_settext,0,integer(text));
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Randomize;
  Edit1.Text := inttostr(random(1000));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Randomize;
  Edit1.Text := inttostr(random(1000));
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -