Example-Extension/ExampleExtension/Extension.cpp
Akash Mozumdar d845478b9e bugfix
2018-07-13 13:26:47 -04:00

29 lines
2.1 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdafx.h"
#define CURRENT_SELECT 0x1000
extern "C"
{
/**
* Param sentence: wstring of the sentence received by NextHooker
* Param info: 64 bit integer that has bit flags set that convey additional info
* Return value: wstring of the sentence that NextHooker should transform the original into
* THIS FUNCTION MAY BE RUN SEVERAL TIMES CONCURRENTLY: PLEASE ENSURE THAT IT IS THREAD SAFE!
*/
std::wstring __declspec(dllexport) NewSentence(std::wstring sentence, DWORD64 info)
{
// This example extension does nothing except place sentences from the hook currently selected by the user into the clipboard
if (info & CURRENT_SELECT)
{
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (sentence.size() + 1) * sizeof(wchar_t));
memcpy(GlobalLock(hMem), sentence.c_str(), (sentence.size() + 1) * sizeof(wchar_t));
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, hMem);
CloseClipboard();
}
return sentence; // Unless you want to change the sentence, please return the original!
}
}