📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Timer1: TTimer;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
qqshuted:boolean; //判断是否关闭的标志
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
h:Thandle;
s:string;
begin
h:=findwindow(nil,'无标题 - 记事本'); //查找"记事本"的父窗口的句柄
h:=FindWindowEx(h,0,'Edit',''); //查找"记事本"的子窗口(文本框)的句柄
s:=memo1.Lines.Text;
if h<>0 then
sendmessage(h,wm_settext,0,integer(s));//发送消息
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
qqshuted:=true;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
var
h:Thandle;
begin
if qqshuted=true then
begin
h:=findwindow('#32770',nil); //查找qq的父窗口
if h<>0 then //如果窗口存在就关闭
postMessage(h, WM_QUIT, 0, 0); //向该窗口发送关闭消息
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
var
h:Thandle;
s:string;
begin
h:=findwindow(nil,'无标题 - 记事本'); //查找"记事本"的父窗口的句柄
h:=FindWindowEx(h,0,'Edit',''); //查找"记事本"的子窗口(文本框)的句柄
s:=memo1.Lines.Text;
if h<>0 then
sendmessage(h,WM_PASTE,0,0);//发送消息
end;
procedure TForm2.Button4Click(Sender: TObject);
var
h:Thandle;
s:string;
begin
h:=findwindow(nil,'无标题 - 记事本'); //查找"记事本"的父窗口的句柄
h:=FindWindowEx(h,0,'Edit',''); //查找"记事本"的子窗口(文本框)的句柄
s:=memo1.Lines.Text;
if h<>0 then
POSTMessage(h,WM_KEYDOWN,VK_RETURN ,0);
end;
procedure TForm2.Button5Click(Sender: TObject);
var
h:Thandle;
s:string;
lLen: Integer;
lBuf: PChar;
begin
h:=findwindow(nil,'无标题 - 记事本'); //查找"记事本"的父窗口的句柄
h:=FindWindowEx(h,0,'Edit',''); //查找"记事本"的子窗口(文本框)的句柄
lBuf:= nil;
lLen:= 500;
GetMem(lBuf, lLen);
if h<>0 then
sendMessage(h,WM_GETTEXT,lLen,integer(lBuf));
showmessage(lBuf);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -