delphi用postMessage发送字符到记事本
演示了PostMessage, SendMessage, WM_CHAR发送汉字。
源代码:
-------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
p rivate
{ P rivate declarations }
public
constructor Create(AOwner: TComponent); override;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
Memo1.Text:='这是猪悟能的postmessage测试';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
hNotePad:=FindWindow('Notepad','无标题 - 记事本');
if hNotePad<>0 then
begin
hedit:=FindWindowEx(hNotePad,0,'edit',nil);
PostMessage(hedit,WM_CHAR,Wparam('B'),0);
Writeln('send');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{ TODO -o猪悟能 : 发送串必须用sendMessage }
hNotePad:=FindWindow(nil,'无标题 - 记事本');
if hNotePad<>0 then
begin
hedit:=FindWindowEx(hNotePad,0,'edit',nil);
SendMessage(hedit,WM_SETTEXT,Length(Memo1.Text),
Integer(PChar(Memo1.Text)));
Writeln('send');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
hNotePad:=FindWindow('Notepad','无标题 - 记事本');
if hNotePad<>0 then
begin
hedit:=FindWindowEx(hNotePad,0,'edit',nil);
PostMessage(hedit,WM_CHAR,Wparam($bd),0);
PostMessage(hedit,WM_CHAR,Wparam($f1),0);
Writeln('send');
end;
end;
end.
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
2019-02-10 笔记:delphi 与 Query
2019-02-10 delphi(假三层之数据访问层)(第一天)
2019-02-10 ADOquery属性中cursortype,LockType属性
2019-02-10 delphi的ActionToolBar控件的使用 [问题点数:50分]
2018-02-10 博客园博文添加自定义右键菜单