📄 main.~pas
字号:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
WM_FRAME_ARRIVE = WM_USER + 32;
type
TMainForm = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Label1: TLabel;
Edit1: TEdit;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
Procedure WMFRAMEARRIVE(var Msg: TMessage); message WM_FRAME_ARRIVE;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
function GetWindowHandle(const WindowCaption: PChar;
const PartialCaption: Boolean = False): HWND;
var
vlHWND: HWND;
vlCaption: PChar;
i: Integer;
begin
Result := 0;
GetMem(vlCaption, 255);
vlHWND := GetWindow(FindWindow(nil, nil), 0);
While (vlHWND <> 0) and (Result = 0) do begin
i := GetWindowText(vlHWND, vlCaption, 255);
if (i > 0) then begin
if (UpperCase(String(vlCaption)) = UpperCase(String(WindowCaption))) then begin
Result := vlHWND;
end
else begin
if PartialCaption and Assigned(AnsiStrPos(vlCaption, WindowCaption)) then begin
Result := vlHWND;
end;
end;
end;
vlHWND := GetWindow(vlHWND, GW_HWNDNEXT);
end;
end;
function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;
var
caption: array[0..256] of Char;
begin
if GetWindowText (Handle, Caption, SizeOf(Caption)-1) <> 0 then
begin
List.Add(Caption) ;
SetWindowText(Handle, PChar('About - ' + Caption)) ;
end;
result :=True;
end;
procedure TMainForm.WMFRAMEARRIVE(var Msg: TMessage);
begin
MainForm.Caption := 'AAA';
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
hwnd: THandle;
PCameraSig: PChar;
CameraSig: String;
lParam: longint;
begin
CameraSig := Edit1.Text;
PCameraSig := PChar(CameraSig);
hwnd := GetWindowHandle(PCameraSig);
//If hwnd <> 0 then
// SetWindowText(hwnd, PChar('Test')) ;
lParam := 40;
Postmessage(hwnd, WM_FRAME_ARRIVE, 0, lParam);
end;
procedure TMainForm.Button3Click(Sender: TObject);
begin
MainForm.Caption := Edit1.Text
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -