I am having trouble thinking of a way of creating a program that monitors anytime the clipboard is used and have it print out in a .txt file (It should be bale to monitor the clipboard for any window/application). I used the Using the Clipboard WIn32, but I am not sure how I can have this process constantly running? I am able to get the clipboard once but my program stops. Should I use a while loop? Basically, my program only runs once when I want it to keep tracking the changes. What should I do?
///
Would Clipboard Format Listener help with what I need?
///
int main()
{
OpenClipboard(nullptr);
HANDLE hData = GetClipboardData(CF_TEXT);
char* pszText = static_cast<char*>(GlobalLock(hData));
string text = pszText;
GlobalUnlock(hData);
CloseClipboard();
cout << text;
return 0;
}