How to access the Clipboard image from the browser?

Asked

Viewed 515 times

3

Does anyone have any idea of how to access the image that is in the Clipboard when we give a Print Screen on any screen? What I need is to have access to the image by giving a ctrl + v in the browser, exactly how this application works: http://pasteboard.co/

the Code I got for the event is this, and it works, however how to access the image of this point?

$(document).bind('paste', function (evt) {
   alert('ctrl + V funciona');
});

Detail: browser : Google Chrome

  • 1

    Well, I made an example these days with html2canvas and it’s on this link: http://answall.com/questions/17450/tirar-print-screen-e-salvar-imagem-automaticamente-em-c/17480#17480. Does it help?

  • opa, I will try to implement.

  • So Harry Potter, I implemented yet it didn’t work out as I expected, let’s say I took a print here, on the stack overflow, and then I went on my site and Ctrl+v, I wanted the print I took out to be for the action you implemented, but what is going to be the image of my application, have some idea?

  • 2

    For security reasons, I’m pretty sure it’s not possible to do this in pure Javascript. Jquery probably doesn’t go much further, as it’s also just a library written in pure JS. MAS... That doesn’t mean you can’t improvise a gambit with the infamous... FLASH. Take a look at Zeroclipboard, it uses a SWF binary to access Clipboard, but in its case, it THROWS things to the clipboard, not PULLS. .

  • 1

    You came to take a look at the Github of the Pasteboard itself?

  • 1

    By the way, the author’s blog has nice information: http://joelb.me/blog/2011/code-snippet-accessing-clipboard-images-with-javascript/

  • I didn’t look Luiz,I didn’t know I had, I’ll analyze, vlw.

  • @Ukyron, I will try to verify the existence by this plugin if I have solution I put!

Show 3 more comments

1 answer

0


I found this plugin http://www.codersgrid.com/2014/02/26/paste-js-retrieve-the-data-from-clipboard-in-javascript/

worked perfectly for my purpose, for copying texts and images.

just include the file . js and use the code below.

paste = $.paste().appendTo('body');
paste.on('pasteImage', function (ev, data){
console.log("dataURL: " + data.dataURL)
});
paste.on('pasteText', function (ev, data){
console.log("text: " + data.text)
});
paste.focus(); // it's actually a hidden div element

// ... when you don't need it anymore
paste.remove();

examples and more information on the link.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.