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

最新文章

  1. UILabel 根据文本内容设置frame
  2. AngularJs的UI组件ui-Bootstrap分享(十四)——Carousel
  3. iscsi: 环境搭建
  4. struts2基础——最简单的一个例子
  5. NBUT 1010 魔法少女(DP)
  6. IIS Server is too busy 解决方法(IIS6)
  7. Ubuntu Vim YouCompleteMe 安装
  8. android打包签名介绍
  9. [Machine Learning] Probabilistic Graphical Models:一、Introduction and Overview(1、Overview and Motivation)
  10. System.in与System.out(标准输入与标准输出)详解
  11. Advanced Installer 9.8打包实录
  12. 分布式版本控制系统Git-----7.Git 使用git rebase合并多次commit
  13. ios协议和委托
  14. [leetcode]984. 不含 AAA 或 BBB 的字符串
  15. SpringBoot学习历程
  16. maven在Idea建立工程,运行出现Server IPC version 9 cannot communicate with client version 4错误
  17. SQL复制表操作
  18. Spark2 生存分析Survival regression
  19. UVa 11093 环形跑道(模拟)
  20. python使用分治法找序列最大值

热门文章

  1. Could not locate executable null\bin\winutils.exe in the Hadoop binaries解决方式 spark运行wordcoult
  2. python---列表、元祖、字典的区别和常用方法
  3. BZOJ1433 [ZJOI2009]假期的宿舍 二分图匹配 匈牙利算法
  4. IDEA控制台问题:At least one JAR was scanned for TLDs yet contained no TLD
  5. PAT (Basic Level) Practise - 写出这个数
  6. sql 的一些总结
  7. java的conllections.sort排序
  8. 20165220实验二《Java面向对象程序设计》
  9. hdu1285 确定比赛名次【拓扑排序】
  10. vue组件通信那些事儿