Trim and clear formattin.
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Trim and clear formattin.
I tried all variants that I found (I think older forum) but none of them works stable.
I need to be able to auto trim begining and ending empty spaces from copied text to clipboard.
Also clear format from copied that like html tags.
I need to be able to auto trim begining and ending empty spaces from copied text to clipboard.
Also clear format from copied that like html tags.
Last edited by ozgurerdogan on 21 Oct 2021, 09:07, edited 2 times in total.
Re: some title
Code: Select all
#Persistent
OnClipboardChange("clipChanged")
clipChanged(Type) {
OnClipboardChange("clipChanged", False)
text := Clipboard, Clipboard := "", Clipboard := Trim(RegExReplace(text, "<.+?>"))
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
OnClipboardChange("clipChanged")
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: some title
Ok hero. Can you please also make one for clear formatting. For example, when I copy text from a web page and paste it to Thunderbird as mail context, I need it to be clear text.
Re: Trim and clear formattin.
The following command will convert formatted text to plain text.
Explained: Clipboard
Code: Select all
Clipboard := Clipboard
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Hello again,
I noted today that I can not copy and paste files in windows. Also when I take a screen shot, I can not copy it to clipboard. Anyway to fix this.?
I noted today that I can not copy and paste files in windows. Also when I take a screen shot, I can not copy it to clipboard. Anyway to fix this.?
Re: Trim and clear formattin.
Code: Select all
#Persistent
OnClipboardChange("clipChanged")
clipChanged(type) {
If WinActive("ahk_class CabinetWClass") || FileExist(plain := Clipboard) || type != TEXT := True
Return
OnClipboardChange("clipChanged", False)
Clipboard := "", Clipboard := Trim(RegExReplace(plain, "<.*?>"))
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
OnClipboardChange("clipChanged")
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Thank you bro. You helped a lot.
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Hello again,
I noticed sometimes I am getting popup message sayin "error happened when copying text to clipboard"
This happens when I copy raw html tags like: <br> <a> etc.
Is there a way to allow those tags to be copied. I am a web master so I need to use these copying a lot.
I noticed sometimes I am getting popup message sayin "error happened when copying text to clipboard"
This happens when I copy raw html tags like: <br> <a> etc.
Is there a way to allow those tags to be copied. I am a web master so I need to use these copying a lot.
Re: Trim and clear formattin.
You stated that you wanted the script to remove HTML tags. In your case, the result is then null.
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Yes you are right. But I should not touch clipboard if it is only containg tags. Not possible?
Re: Trim and clear formattin.
Code: Select all
#Persistent
OnClipboardChange("clipChanged")
clipChanged(type) {
If WinActive("ahk_class CabinetWClass") || FileExist(plain := Clipboard) || type != TEXT := True
Return
If ("" = text := Trim(RegExReplace(plain, "<.*?>")))
Return
OnClipboardChange("clipChanged", False), Clipboard := "", Clipboard := text
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
OnClipboardChange("clipChanged")
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
You are a life saver )
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
One more thing, sometimes when I paste I see long spaces at end not sure if it is tab or only spaces. Is the code not trimming them or they are something different maybe related to app currently being pasted.
Re: Trim and clear formattin.
What is your example?
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
You can see screenshot:
https://yadi.sk/d/fH_obW9KJcivGg
It is an app has windows with inputs. But if I paste string to notepad then there is no space at end. Only on this app.
Also if I recopy non-spaced text to app again then there is no empty space.
https://yadi.sk/d/fH_obW9KJcivGg
It is an app has windows with inputs. But if I paste string to notepad then there is no space at end. Only on this app.
Also if I recopy non-spaced text to app again then there is no empty space.
Re: Trim and clear formattin.
When your script is not running, you can view the invisible characters by pasting the string at the following Web page.
https://www.soscisurvey.de/tools/view-chars.php
https://www.soscisurvey.de/tools/view-chars.php
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Cool. And I got:
⟶ CR LF
But this is not a big deal. Script is mostly helpful.
⟶ CR LF
But this is not a big deal. Script is mostly helpful.
Re: Trim and clear formattin.
You can trim those, too.
Code: Select all
#Persistent
OnClipboardChange("clipChanged")
clipChanged(type) {
If WinActive("ahk_class CabinetWClass") || FileExist(plain := Clipboard) || type != TEXT := True
Return
If ("" = text := Trim(RegExReplace(plain, "<.*?>"), " `t`r`n"))
Return
OnClipboardChange("clipChanged", False), Clipboard := "", Clipboard := text
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
OnClipboardChange("clipChanged")
}
-
- Posts: 47
- Joined: 27 Apr 2017, 02:32
- Contact:
Re: Trim and clear formattin.
Thanks that worked too. I though those were also being trimmed.
Re: Trim and clear formattin.
The default trim characters for Trim are Space and Tab.