i need help clipboard

Jun 26, 2014 at 3:50pm
need a code that will calculate the length of characters in the clipboard if the length of characters will be equal to 15 to the contents of the clipboard is to be changed to "hello world"
can someone help me weak I know cpp


my code
HGLOBAL hText;
char *pText;
hText = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 100);
pText = (char*)GlobalLock(hText);
strcpy(pText, "helloa");
GlobalUnlock(hText);

OpenClipboard(NULL);
EmptyClipboard();


SetClipboardData(CF_TEXT, hText);
CloseClipboard();
Last edited on Jun 26, 2014 at 3:51pm
Jun 27, 2014 at 8:21am
calculate the length of characters in the clipboard

The data put on the clipboard can be in a variety of types simultaneously. An image will be different from plain text. So the question needs to be clarified as to what range of formats you need to check.

As it stands, the question is ambiguous.
Last edited on Jun 27, 2014 at 8:21am
Jun 27, 2014 at 2:35pm
I just want to change the value from the clipboard, if the clipboard will be 15 characters digits
This code does not work I do not know why
#include <windows.h>



int main(){

while(1){

int length;

HGLOBAL hText;
char *pText;
hText = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 100);
pText = (char*)GlobalLock(hText);




if(length = strlen(pText) == 15){


strcpy(pText, "helloa");
GlobalUnlock(hText);



OpenClipboard(NULL);
EmptyClipboard();


SetClipboardData(CF_TEXT, hText);
CloseClipboard();


}}
}



Last edited on Jun 27, 2014 at 2:36pm
Jun 27, 2014 at 4:48pm
You should register your window as clipboard viewer using AddClipboardFormatListener() function and respond to WM_CLIPBOARDUPDATE message.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649033%28v=vs.85%29.aspx

You will be notified automatically by windows every time the clipboard content is changed.

This requires a GUI program with a message loop, not a console application.
Last edited on Jun 27, 2014 at 4:49pm
Topic archived. No new replies allowed.