clipboard

Get the selected text of a web page in google chrome extension

孤街浪徒 提交于 2019-12-03 17:22:07
I am developing a Google Chrome extension. When a popup is clicked, I would like the input box present in the popup.html file to contain the selected text of the current webpage. Example textbox: <input id="searchBox" type="text" /> When text is selected in a webpage, the textbox should contain the selected word. I tried with chrome.extension.getBackgroundPage().getSelection() but it is not working. There was a thread about this on google groups: how to get HTML code from selection? var selection = window.getSelection(); var range = selection.getRangeAt(0); if (range) { var div = document

Alpha becomes black when coming from clipboard on Mozilla Firefox and MS Edge

浪尽此生 提交于 2019-12-03 16:36:43
I'm using a code from here to paste images from clipboard on a page. It works fine in all browsers (Chrome, Firefox, Edge and Opera). The problem is: when the image is a PNG or GIF with alpha channel (transparent areas), the alpha becomes black in Firefox and Edge. Here's the code snippet ( or jsfiddle if you prefer ): document.getElementById('pasteArea').onpaste = function (event) { // use event.originalEvent.clipboard for newer chrome versions var items = (event.clipboardData || event.originalEvent.clipboardData).items; console.log(JSON.stringify(items)); // will give you the mime types //

Platform independent tool to copy text to clipboard

邮差的信 提交于 2019-12-03 16:07:15
问题 I am trying to write a function that copies a string parameter to the clipboard . I intend to use this in a Python script that I've been working on. This is what I have so far (found most this snippet on another stack overflow post): from tkinter import Tk def copy_to_clipboard(text): text = str(text) r = Tk() r.withdraw() r.clipboard_clear() r.clipboard_append(text) r.destroy() My problem is that when the script stops, the copied text is no longer on the clipboard. Is there any possible

How do I safely and correctly create a backup of the Windows clipboard?

对着背影说爱祢 提交于 2019-12-03 14:05:34
I'm trying to create a backup of the Windows clipboard. Basically what I'm doing is using EnumClipboardFormats() to get all of the formats that exist on the clipboard currently, and then for each format, I'm calling GetClipboardData(format) . Part of backing up the data obviously involves duplicating it. I do that by calling GlobalLock() (which "Locks a global memory object and returns a pointer to the first byte of the object's memory block." ) on the data returned by GetClipboardData() , then I fetch the size of the data by calling GlobalSize() , and then finally I do a memcpy() to duplicate

How can I get the standard iPhone Copy bubble to appear on a UIImage?

拟墨画扇 提交于 2019-12-03 13:34:16
问题 In iPhoto, I can simply hold my finger over an image to get a "Copy" popup (like the popup you see in text boxes). In my UIImageView's, this is not the case. How can I enable it? 回答1: You can manually display the Cut / Copy / Paste menu using the UIMenuController class. For example, the following code will display the menu, centered on your image: [self becomeFirstResponder]; UIMenuController *copyMenuController = [UIMenuController sharedMenuController]; [copyMenuController setTargetRect

How to obtain data from clipboard in Firefox

旧时模样 提交于 2019-12-03 13:03:57
问题 I would like to trigger onpaste event on element to retrieve data in clipboard (I want to check if image exists in clipboard and upload it into the server). It works perfect on Chrome: $('#textarea')[0].onpaste = function(event) { var items = event.clipboardData.items; if (items.length) { var blob = items[0].getAsFile(); var fr = new FileReader(); fr.onload = function(e) { alert('got it!'); } fr.readAsDataURL(blob); } } Does not work on Firefox: event.clipboardData.items does not exists. Do

Can't paste into MacVim

安稳与你 提交于 2019-12-03 12:24:32
I copy text from outside of Vim. ⌘V in other apps pastes text without problem. In MacVim, it doesn't work. In Insert Mode, nothing appears. In Normal Mode, I get E353: Nothing in register + . This happens when set clipboard=unnamed is on or off. Oddly enough, this was working before. What's wrong? If you are using tmux and sometimes you initially launch MacVim via the mvim command-line program, then you might be encountering the problem that prompted me to write the reattach-to-user-namespace command . My guess is that clipboard access worked on prior occasions because you happened to have

Copy a string to clipboard from Mac OS command line

这一生的挚爱 提交于 2019-12-03 12:24:12
is there a way to copy a string to clipboard from command line? To be more specific, I want to make a script which copies my email address to clipboard, so that when I need to insert it several times for logging in / register, I just run the script once and then CMD+V it whenever I need. I heard of pbcopy , but I think this is not my case. Any suggestion? Many thanks! You need to pipe the output of your script to pbcopy For example: ./somescript.sh | pbcopy GM Lucid echo 'your-email@example.com' | pbcopy (as @Jonathan Leffler stated above) Or see the answer for the related question on piping

Editing clipboard data when copying/pasting from a website

你离开我真会死。 提交于 2019-12-03 11:43:08
问题 I have seen a few sites now where if you highlight text of an article, copy it, and then paste in they can add more text to it. Try copying and pasting a section of text from an article at http://belfasttelegraph.co.uk/ and you'll see what I mean - they add a link to the original article in the pasted text. How is this done? I'm assuming there is some javascript at work here 回答1: This is a good effect, you can see the scripting that is fired on copy using Firebug (in Firefox). Start up

Is it possible to create instance of ClipboardEvent in Chrome?

丶灬走出姿态 提交于 2019-12-03 11:21:54
问题 I need to programmatically create a ClipboardEvent instance in Chrome. But when I run the constructor: new ClipboardEvent("paste", {dataType: "text/plain", data: "some data"}) It throws the following error: Uncaught TypeError: Illegal constructor The constructor works as intended in Firefox. Checked MDN and W3C spec and they don't mention anything about it being illegal to create instances of ClipboardEvent. Is it possible to create an instance of ClipboardEvent in Chrome in any other way? I