相关疑难解决方法(0)

WM_GETTEXT 不适用于使用 delphi 的其他进程

我正在编写此代码以从另一个应用程序(进程)中选择一些文本行,但问题是我无法处理此应用程序并获取所选文本完美选择的文本但无法复制此文本,是否存在有什么方法可以在 delphi 中模拟 Ctrl+C 命令?这是我的代码

    SetCursorPos(300, 300);
  mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  SetCursorPos(300, 350);
  mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  if not AttachThreadInput(GetCurrentThreadId,
    GetWindowThreadProcessId(GetForegroundWindow), true) then
    RaiseLastOSError;
  try

    SendMessage(GetFocus, WM_GETTEXT, 0, 0);
    lookup_word := clipboard.astext;
    CurvyEdit1.Text := lookup_word;
  finally
    AttachThreadInput(GetCurrentThreadId,
      GetWindowThreadProcessId(GetForegroundWindow), false);
  end;
Run Code Online (Sandbox Code Playgroud)

delphi

-2
推荐指数
1
解决办法
2714
查看次数

标签 统计

delphi ×1