HanDs
NO.2

[Delphi文章] 枚举窗口所有控件句柄 





学习中请遵循国家相关法律法规,黑客不作恶。没有网络安全就没有国家安全

本站需要登陆后才能查看


Function OK(h:HWND; lParam:LPARAM):Boolean; stdcall;
begin
if not (h > 0) then exit;
result := true;
GetClassName(h, NA, 256);
EnableWindow(h,true);
SaveInfo('获取的句柄:' + inttostr(h));
PInteger(lParam)^ := h;
//nIEDit2 := GetWindowLong(h, GWL_ID);
//tmpWnd2 := GetDlgitem(HMainWnd, nIEDit2);
//tmpWnd1 := FindWindowEx(HMainWnd, 0, 'Edit', 'Edit1');
//  GetCursorPos(pt);
//  tmpWnd1 := WindowFromPoint(pt);
//SendMessage(tmpWnd1, WM_GETTEXTLENGTH, 0, 0);
//Buf:= LongInt(mText);
//SendMessage(tmpWnd1, WM_GETTEXT, 1024, Buf);
try
GetMem(mText,1024);
SendMessage(h, WM_GETTEXTLENGTH, 0, 0);
Buf:= LongInt(mText);
SendMessage(h, WM_GETTEXT, 1024, Buf);
 finally
//  FreeMem(mText,1024);
if (StrPas(NA) = 'Edit') then
  Edit1Text := StrPas(mText);
if (StrPas(NA) = 'Edit') then
  Edit2Text := StrPas(mText);

  GetDlgItemText(tmpWnd1, nIEdit1, tmpChar, 255);
  SaveInfo('获取了: 【' + StrPas(NA) + ' - ' + StrPas(mText) + '】');
 end;
end;

 

 

      EnumChildWindows(HMainWnd, @OK, Integer(@Th)); //枚举窗口所有控件句柄
      SendMessage(Th, WM_lbuttondown, 0, 0);//模拟鼠标左键按下
      SendMessage(Th, WM_lbuttonup, 0, 0);//模拟鼠标左键松开


学习中请遵守法律法规,本网站内容均来自于互联网,本网站不负担法律责任
枚举 窗口 所有 控件
#1楼
发帖时间:2016-7-9   |   查看数:0   |   回复数:0
游客组