nodejs c++ 获取鼠标选中的数据注意不是复制的内容而是选中的内容 一下是官方的描述请根据这个思路用C++实现并包装成一个方法返回值是charThis code help you to get focused control text in focused window i hope that helps Gain focus control You could get the curren
#include <Windows.h>
char* GetSelectedText() { HWND hWnd = GetForegroundWindow(); DWORD pid; DWORD tid = GetWindowThreadProcessId(hWnd, &pid); AttachThreadInput(GetCurrentThreadId(), tid, TRUE); HWND hFocused = GetFocus(); AttachThreadInput(GetCurrentThreadId(), tid, FALSE); const int MAX_LENGTH = 1024; wchar_t buffer[MAX_LENGTH]; SendMessageW(hFocused, WM_GETTEXT, (WPARAM)MAX_LENGTH, (LPARAM)buffer); char* result = new char[MAX_LENGTH]; wcstombs(result, buffer, MAX_LENGTH); return result;
原文地址: https://www.cveoy.top/t/topic/gfQH 著作权归作者所有。请勿转载和采集!