TagUI icon indicating copy to clipboard operation
TagUI copied to clipboard

Keyboard Paste automatically trim all the contents beginning space

Open lookang opened this issue 2 years ago • 4 comments

I've been using TagUI to do copy and pasting of website contents that contain tables of data. I would eventually copy this data into an Excel spreadsheet.

I find sometimes the table data will have a space at the beginning of the cell, and in order for the formulas to work I need to do a find [space] and replace with empty using TagUI.

I'm wondering if a new update can include this new feature, before pasting Keyboard [cmd]v the data in the clipboard is already trim() of the extra spaces in the beginning of the cells.

Example 600.00 50000

After paste 600.00 50000

For people who are using TagUI I believe this will be a welcome feature.

lookang avatar Oct 18 '22 05:10 lookang

is possible to share the code ?

marcelocecin avatar Oct 18 '22 17:10 marcelocecin

    click secondmarker.png 
    wait 3
    click secondmarker.png 
    //wait 2
    wait 2
    keyboard [down] 
    //temp = []
    //temp = clipboard()
    clipboard() = del_chars(clipboard(), ' ')
    keyboard [cmd]v

i just introduced clipboard() = del_chars(clipboard(), ' ') but there is an error now

wait 2 keyboard [down] ERROR - left side of assignment is not a reference.

but i think i need to keep the "contents" inside the [cmd]c which i assume is clipboard() how to modify the code to keep the "contents" but remove the spaces in the contents?

example of contents could be

[[ 500, 600],[ 700, 800]] i need [[500,600],[700,800]] due to need to paste inside an XLSX file sheet for the formulas to work

lookang avatar Oct 19 '22 14:10 lookang

https://www.w3schools.com/howto/howto_js_copy_clipboard.asp
type //*[@id="myInput"] as [clear]500, 600
click //*[@id="main"]/div[3]/button
text_contents = clipboard()
echo `text_contents`
echo Removing spaces . . .
re = /\s/g
new_text = text_contents.replace(re,'')
echo `new_text`
clipboard(new_text)
type //*[@id="myInput"] as [clear]`new_text `
echo Done !

marcelocecin avatar Oct 19 '22 17:10 marcelocecin

Hi @lookang you can also use the del_chars() helper function, like this:

text = ' 500'
newText = del_chars(text, ' ')
echo `newText`

ruthtxh avatar Oct 20 '22 02:10 ruthtxh

Closing but please ping back if this is still relevant or an issue.

kensoh avatar Aug 19 '24 12:08 kensoh