I’m trying to copy several items on a single web page in order to paste them into a row on a pre-formatted spreadsheet. To make this easy, I’m trying to use a tab to separate each value so that they get pasted into the right cells. I’ve been trying various methods, but none seem to work. I’m using a test script for now that is basically:
store data !clipboard
I’ve tried the following separators within the data and got the results noted
Separator
Result
An actual tab character
Converts to \t in the !clipboard variable, appears as a space when I paste the data
This is a good question. I thought aa\tbb should work, but it does not. It just creates a space when I paste it in Excel. But aa\nbb works as expected, it creates a new line in the editor, and a new row in Excel (as expected).
Many thanks Ulrich. For some reason ALT+TAB didn’t work, even though it’s fine manually. I’m running Linux Mint using XFCE though and I was able to use CTRL+ALT and right arrow with the spreadsheet in the next workspace, which works perfectly, and also keeps the spreadsheet where I wanted it as well.
It’s been 6 years since this topic was created, but I’d like to revisit it because it still broken in 2024. I’m going to add a test script and show some sample data to show it’s broken in the hopes it might get fixed. My use case is the same as the original poster - pasting tab separated data into a spreadsheet. The workaround isn’t practical for me because I’m pasting in several hundred cells of data (call it 5KB or more) and XType is way too slow. The TSV is being converted from a CSV of scraped data. The storing of the \t escape string to the clipboard is just wrong. I tried this on both Edge and Chrome on Windows 11.
Here’s a test script that reads in the current contents of the clipboard, writes a simple TSV string to a variable, sends that variable to the clipboard, and reads the contents of the clipboard again.
My first test started by preloading the clipboard with the string “junk” and then running the script. Here’s the dump of variables afterwards. clipboardBefore shows “junk” as expected. testString shows the \t and \n escape characters as expected. Both the !clipboard and clipboardAfter strings show the \n but not the \t (a space instead). Pasting the data into Notepad confirms that the clipboard has a space and not a tab.
My second test was to manually put the desired TSV string onto the clipboard (copied it from Notepad) and ran the script again. clipboardBefore and testString show the correct data. Both !clipboard and clipboardAfter again show the incorrect data. Pasting into Notepad confirms it’s wrong.
Just a guess: Is this maybe the Windows clipboard itself? Because store | ${!clipboard} | var grabs the value from the clipboard, not internal storage.
Just a guess: Is this maybe the Windows clipboard itself? Because store | ${!clipboard} | var grabs the value from the clipboard, not internal storage.
In the second test, clipboardBefore has the correct value, so that verifies that reading the clipboard is OK. It’s only writing that’s a problem and oddly \n works, but not \t. I didn’t think to try other escape characters because I’ve never used them or had a need for them.