我正在尝试制作一个可以处理某些文本的程序(删除所有“。”,将 2 个文本块放在一起并将结果粘贴到另一个程序中,使用 TAB 遍历文本字段。
这是我现在在代码中的位置:
unit Banri;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Clipbrd, sndkey32;
type
TForm1 = class(TForm)
EditTexto: TEdit;
ButtonGO: TButton;
procedure ButtonGOClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SL: TStringList;
Count: Integer;
Appwin : hWnd;
implementation
{$R *.dfm}
var
TextoCompleto: String;
procedure TForm1.ButtonGOClick(Sender: TObject);
begin
TextoCompleto:= Trim(EditTexto.Text);
Appwin:= FindWindow(PChar(0),'Banrisul');
if Appwin <> 0 then
begin
StringReplace(TextoCompleto, '.', '', [rfReplaceAll, rfIgnoreCase]);
SL:= TStringList.Create;
try
ExtractStrings([' '], [], PChar(TextoCompleto), SL);
WriteLn(SL.Text);
ReadLn;
finally
SL.Free;
end;
Count:= 0;
while Count <> SL.Count - 1 do
begin
Clipboard.AsText:= SL[Count]; //place text in clipboard
//if Clipboard.HasFormat(CF_TEXT) then
//do something with text
ShowMessage(Clipboard.AsText);
PostMessage(Appwin.Handle, WM_KEYDOWN, VK_TAB, 0);
PostMessage(FindWindow(PChar(0),'Banrisul').Handle, WM_KEYUP, VK_TAB, 0);
end; //while Count <> SL.Count - 1 do
SL.Free;
end; //if Appwin <> 0 then
end;
end.
它给出了一个错误: PostMessage(Appwin.Handle, WM_KEYDOWN, VK_TAB, 0);
为什么 Appwin 中的结果不能与 .Handle 一起使用?