Local-MT-Extension/ExampleExtension/Extension.cpp

36 lines
2.5 KiB
C++
Raw Normal View History

2018-07-30 05:35:40 +08:00
<EFBFBD><EFBFBD>#include "stdafx.h"
2018-09-02 00:41:53 +08:00
//#define COPY_CLIPBOARD
//#define EXTRA_NEWLINES
2018-07-30 05:35:40 +08:00
2018-09-02 00:41:53 +08:00
/**
* Param sentence: entence received by NextHooker (UTF-16).
* Param miscInfo: pointer to start of singly linked list containing misc info about the sentence.
* Return value: whether the sentence was modified.
* NextHooker will display the sentence after all extensions have had a chance to process and/or modify it.
* THIS FUNCTION MAY BE RUN SEVERAL TIMES CONCURRENTLY: PLEASE ENSURE THAT IT IS THREAD SAFE!
*/
bool ProcessSentence(std::wstring& sentence, const InfoForExtension* miscInfo)
2018-07-30 05:35:40 +08:00
{
2018-09-02 00:41:53 +08:00
#ifdef COPY_CLIPBOARD
// This example extension automatically copies sentences from the hook currently selected by the user into the clipboard.
if (GetProperty("current select", miscInfo))
2018-07-30 05:35:40 +08:00
{
2018-09-02 00:41:53 +08:00
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 2) * sizeof(wchar_t));
memcpy(GlobalLock(hMem), sentence, (sentence.size() + 2) * sizeof(wchar_t));
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, hMem);
CloseClipboard();
2018-07-30 05:35:40 +08:00
}
2018-09-02 00:41:53 +08:00
return false;
#endif // COPY_CLIPBOARD
#ifdef EXTRA_NEWLINES
// This example extension adds extra newlines to all sentences.
sentence += L"\r\n";
return true;
#endif // EXTRA_NEWLINES
2018-07-30 05:35:40 +08:00
}
2018-07-12 08:07:22 +08:00