Delphi 获取当前鼠标下的控件内容

主要函数:

GetCursorPos;//获取鼠标的位置

WindowFromPoint;//获取制定point下的handle

GetClassName;//获取类的名字

 

function TForm1.GetEditText: string;
var
  Point: TPoint;
  Name: array[0..255] of Char;
  Buffer: array[0..1023] of Char;
  AHandle: THandle;
begin
  //取得鼠标位置
  GetCursorPos(Point);
  //取得当前窗口句柄
  AHandle := WindowFromPoint(Point);
  GetClassName(AHandle, Name, Length(Name));
  if AHandle = Self.Handle then
    Exit;
  SendMessage(AHandle, WM_GETTEXT, 1023, Integer(@Buffer));
  Caption := StrPas(Name);
  Result := StrPas(Buffer);  
end;

 

procedure TForm1.tmr1Timer(Sender: TObject);
begin
  mmo1.Lines.Text := GetEditText;
end;

 

https://blog.csdn.net/lwstar23133/article/details/6773883

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2021-09-09
  • 2022-03-01
  • 2022-01-08
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案