remove all tabs from clipboard headache

Get help with using AutoHotkey and its commands and hotkeys
nedab
Posts: 2
Joined: 03 Oct 2019, 05:54

remove all tabs from clipboard headache

03 Oct 2019, 06:05

Hi all,

I am very new to AHK v1.1.30.03 and so far love the app and see a lot of potential, unfortunately I have got my head stuck on what I believe to a simple script.
I would like to remove all Tabs from text in the clipboard and send it (unable to copy paste large SQL scripts over citrix session, but tabbing goes crazy in SQL)

I am able to send the clipboard without issue , but for the life of me I cannot figure out why it is not removing Tabs?!? its been a few days and much of the help out there is for older versions which I am not 100% sure is compatible as I have been trying loops and many other lines just copied from Forums posts etc etc ?

Many thanks in Advance.


Code: Select all

F2::
Clipboard=%Clipboard% ;remove any formatting
StringReplace, clipboard, clipboard, "`t", , All   ;trying to remove tabs
Send {text} %Clipboard%   ;send clipboard to screen
hd0202
Posts: 145
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: remove all tabs from clipboard headache

03 Oct 2019, 07:13

without "

Code: Select all

StringReplace, clipboard, clipboard, `t, , All   ;trying to remove tabs
Hubert
User avatar
boiler
Posts: 3282
Joined: 21 Dec 2014, 02:44

Re: remove all tabs from clipboard headache

03 Oct 2019, 08:48

And since StringReplace is deprecated, you might want to use StrReplace instead:

Code: Select all

clipboard := StrReplace(clipboard, "`t")
nedab
Posts: 2
Joined: 03 Oct 2019, 05:54

Re: remove all tabs from clipboard headache

03 Oct 2019, 09:54

hd0202 wrote: without "

Code: Select all

StringReplace, clipboard, clipboard, `t, , All   ;trying to remove tabs
Hubert
I get the following Error if I remove the quotes.

Code: Select all

Error at line 3.
Line Text: StrReplace, clipboard, clipboard, t., All Error This line does not contain a recognized action.
The program will exit.


boiler wrote: And since StringReplace is deprecated, you might want to use StrReplace instead:

Code: Select all

clipboard := StrReplace(clipboard, "`t")
I now have the following script, but it doesn't make any difference, it still fails to remove tab, I have given an example below of the issue I am getting.

Code: Select all

F2::
Clipboard=%Clipboard% ;remove any formatting
clipboard := StrReplace(clipboard, "`t")   ;trying to remove tabs
Send {text} %Clipboard%   ;send clipboard to screen


Original with normal tabbing

Code: Select all

WHILE (1=1)
    BEGIN;
        FETCH NEXT
           FROM partitions
           INTO @objectid, @indexid, @partitionnum, @frag;
        IF @@FETCH_STATUS < 0 BREAK;
Copied text into SQL remote session, it still works, it is just very very messy.

Code: Select all

WHILE (1=1)
     BEGIN;
	         FETCH NEXT
			            FROM partitions
						           INTO @objectid, @indexid, @partitionnum, @frag;
								           IF @@FETCH_STATUS < 0 BREAK;

I have tried a variation of the following to detect the Tab, but maybe I am understanding how the script is built ??
`t
"`t"
\t
\\t
"\\t"
"\t"
%A_Tab%
A_Tab
"A_Tab"
"%A_Tab%"
gregster
Posts: 3410
Joined: 30 Sep 2013, 06:48

Re: remove all tabs from clipboard headache

03 Oct 2019, 10:22

nedab wrote:
03 Oct 2019, 09:54
Original with normal tabbing

Code: Select all

WHILE (1=1)
    BEGIN;
        FETCH NEXT
           FROM partitions
           INTO @objectid, @indexid, @partitionnum, @frag;
        IF @@FETCH_STATUS < 0 BREAK;
This one above contains no tabs at all, just spaces...
Copied text into SQL remote session, it still works, it is just very very messy.

Code: Select all

WHILE (1=1)
     BEGIN;
	         FETCH NEXT
			            FROM partitions
						           INTO @objectid, @indexid, @partitionnum, @frag;
								           IF @@FETCH_STATUS < 0 BREAK;
This one contains tabs and spaces at the beginning of most lines.

So, you will have to remove spaces as well, for example with LTrim() and looping through each line, to remove all indentation.
User avatar
boiler
Posts: 3282
Joined: 21 Dec 2014, 02:44

Re: remove all tabs from clipboard headache

03 Oct 2019, 10:32

nedab wrote:
03 Oct 2019, 09:54
hd0202 wrote: without "

Code: Select all

StringReplace, clipboard, clipboard, `t, , All   ;trying to remove tabs
Hubert
I get the following Error if I remove the quotes.

Code: Select all

Error at line 3.
Line Text: StrReplace, clipboard, clipboard, t., All Error This line does not contain a recognized action.
The program will exit.
Did you copy his line just like he showed it? You still need the ` (backtick character), don't add a period, and you need the blank parameter (extra comma) before the All exactly like this:

Code: Select all

StringReplace, clipboard, clipboard, `t, , All   ;trying to remove tabs



nedab wrote:
03 Oct 2019, 09:54
I now have the following script, but it doesn't make any difference, it still fails to remove tab, I have given an example below of the issue I am getting...
For one thing, remove the space in between {text} and %Clipboard% in your script because that extra space is getting sent.

It works for me. Are you sure you're pasting by pressing F2 and not by pasting with Ctrl+v?

Edit: Just saw gregster's post. But still note the possible issues you had in the StringReplace version where it looks like you removed the backtick and the blank parameter, and you should remove the space between {text} and %Clipboard%.
User avatar
Chunjee
Posts: 239
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: remove all tabs from clipboard headache

03 Oct 2019, 12:48

using .replace from biga.ahk

Code: Select all

A := new biga()
clipboard := A.replace(clipboard, "/(\t)/", "")
msgbox, % "-" cliboard "-"
clipboard := A.replace(clipboard, A_Tab, "") ;also valid

If you continue to have trouble, I'm beginning to suspect the tabs are not actual tabs. Could be some &emsp; tomfoolery.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], dave444344, Google [Bot], Groot, spencer and 224 guests