Advertisement
Guest User

Untitled

a guest
May 21st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. void GetClipboardText ( char * buff )
  5. {
  6.     if ( OpenClipboard ( NULL ) )
  7.     {
  8.          HANDLE hData = GetClipboardData ( CF_TEXT );
  9.          char * chBuffer = ( char * ) GlobalLock ( hData );
  10.          strcpy ( buff, chBuffer );
  11.          GlobalUnlock ( hData );
  12.          CloseClipboard ( );
  13.     }
  14. }
  15.  
  16. int main ( int argc, char *argv [ ] )
  17. {
  18.     char buff[ 1024 ];
  19.     GetClipboardText ( buff );
  20.     printf ( "text in clipboard: %s\n\n", buff );
  21.    
  22.     while ( 1 )
  23.     {
  24.          char temp[ 1024 ];
  25.          GetClipboardText ( temp );
  26.          
  27.          if ( strcmp ( buff, temp ) != 0 )
  28.          {
  29.               printf ( "new text in clipboard: %s\n\n", temp );
  30.               wsprintf ( buff, "%s", temp );
  31.          }
  32.          Sleep ( 500 );
  33.     }
  34.     getchar ( );
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement