delphi获取指定窗体句柄,该怎么处理
发布网友
发布时间:2022-12-16 14:28
我来回答
共1个回答
热心网友
时间:2024-07-30 01:42
找某个窗口的某个BUTTON
,例子很简单就是用了
FindWindow,EnumChildWindows两个函数,要找的具体BUTTON在EnumChildWindowsProc回调函数中
Delphi(Pascal)
codefunction
EnumChildWindowsProc(hwd:
Hwnd):
Boolean;
stdcall;
begin
Result
:=
true;
GetClassName(hwd,
buffer,
256);
if
String(Buffer)
<>
'Button'
then
Exit;
getwindowtext(hwd,
buffer,
256);
if
String(Buffer)
<>
'验证全部'
then
Exit;
h
:=
hwd;
end;
procere
TForm1.Timer1Timer(Sender:
TObject);
var
hwnd1,hwnd2,hwnd3,hwnd4:
DWORD;
begin
h
:=
0;
hwnd1
:=
FindWindow(nil,
'代理猎手');
if
hwnd1
<>
0
then
begin
if
EnumChildWindows(hwnd1,
@EnumChildWindowsProc,
0)
then
if
h
=
0
then
exit;
SendMessage(h,
WM_LBUTTONDOWN
,
0,
0);
SendMessage(h,WM_LBUTTONUp,
0,
0);
end;
end;