-2

is it possible to take something i have copied to clipboard and have it save as an int or a var? i am trying to make something to take something i have copied to clipboard and make it able to paste it into a text document. is there any way to do this?

i have not found any good answers explaining this so any help would be appreciated.

drescherjm
  • 10,365
  • 5
  • 44
  • 64
EvenNine
  • 1
  • 1
  • 4
    Are you aware that there are many operating systems in the world, and the process for doing that is completely different on each operating system, so you need to specify what your operating system is? – Sam Varshavchik Dec 30 '20 at 03:24

1 Answers1

2
#include <windows.h>
//get data
HANDLE clip;
string clip_text = "";

if (OpenClipboard(NULL)) 
{
  clip = GetClipboardData(CF_TEXT);
  clip_text = (char*)clip;
  cout << "Text: "<<clip_text<<endl<<endl;
  CloseClipboard();
}

works with WINDOWS ONLY!

Check these links: http://www.cplusplus.com/forum/beginner/27836/
https://learn.microsoft.com/en-us/cpp/mfc/clipboard-using-the-windows-clipboard?view=msvc-160

Nine Tails
  • 378
  • 3
  • 15