///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
///////////////////////////////
TEXT* input_txt=
{
layer=31;
pos_x=100;
pos_y=100;
strings=1;
flags = TRANSLUCENT | SHOW;
}
void from_clipboard()
{
STRING *temp="";
STRING *final="";
if(IsClipboardFormatAvailable(CF_OEMTEXT))//is this format available ?
{
if(OpenClipboard(hWnd))//open the clipboard
{
HANDLE data=GetClipboardData(CF_OEMTEXT);
if(data!=NULL)//got handle ?
{
temp=GlobalLock(data);//lock
if(temp!=NULL)//got it ?
{
final=temp;
}
GlobalUnlock(data);//unlock
}
CloseClipboard();//close clipboard
}
}
if((input_txt.pstring)[0]==NULL)(input_txt.pstring)[0]=str_create(final);
else str_cpy((input_txt.pstring)[0],final);
}
void to_clipboard(char *content)
{
int len=str_len(content)*sizeof(char);
if(len==0) return;//data was empty
if(OpenClipboard(hWnd))//open the clipboar
{
if(EmptyClipboard())//emptied?
{
HANDLE mem=GlobalAlloc(GMEM_MOVEABLE,len+1);//alloc mem
if(mem)//non zero ?
{
char* temp=GlobalLock(mem);
memcpy(temp,content,len);
if(!SetClipboardData(CF_OEMTEXT,mem))
{
GlobalFree(mem);
CloseClipboard();
return;
}
GlobalUnlock(mem);
CloseClipboard();
}
}
}
}
void main()
{
warn_level=6;
to_clipboard("hello this is a test");
from_clipboard();
}