Textractor_test/extensions/copyclipboard.cpp

16 lines
542 B
C++
Raw Normal View History

#include "extension.h"
2018-09-23 03:08:31 +08:00
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
2018-11-04 11:26:27 +08:00
if (sentenceInfo["current select"] && sentenceInfo["hook address"] != -1)
{
2018-11-15 13:06:10 +08:00
if (!OpenClipboard(FindWindowW(NULL, L"Textractor"))) return false;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 2) * sizeof(wchar_t));
memcpy(GlobalLock(hMem), sentence.c_str(), (sentence.size() + 2) * sizeof(wchar_t));
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, hMem);
2018-11-15 13:06:10 +08:00
GlobalUnlock(hMem);
CloseClipboard();
}
return false;
}