AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ClipCleaner

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
DaTex



Joined: 21 Nov 2006
Posts: 4
Location: Texas, USA

PostPosted: Tue Sep 08, 2009 3:15 pm    Post subject: ClipCleaner Reply with quote

ClipCleaner
ClipCleaner is a tiny utility program I wrote that "cleans" the contents of the clipboard by converting it to plain text. Of course this is only applicable to text-based contents, it would be useless to try and "clean" an image or other binary object on the clipboard.

When the program is run, it remains in memory with a small icon on the toolbar. After copying text to be cleaned, press Win + C (where Win is the Windows key) and the clipboard contents will be converted to text. This is really a very small script: one AutoHotKey command does all of the work. The rest of the file consists of comment lines and tray settings.

My primary uses for this are:

1. It is faster than using Paste Special in Microsoft Office applications when I am trying to paste only text.
2. If you need a list of filenames from an Explorer window, select the files and copy them to the clipboard. The file names are not available as ASCII text at this point, they are in a special format so that Windows can link to the files when you paste the names. But now if you WANT only the names, pressing Win+C will "clean" them up and convert them into their text equivalents (with full path names).

Comments and suggestions are welcome!

http://www.autohotkey.net/~DaTex/ClipCleaner/

DaTex

Change Log
Version 1.0 (Current Version, 8 September 2009)
Cleans text on clipboard.
Menu tray icon set to Shell32.dll number 145 (a checkmark on a file)
Set the menu tray tooltip to remind the user what key activates it
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Tue Sep 08, 2009 9:27 pm    Post subject: Reply with quote

Hi DaTex,

Nice little script. I modified it a small bit


Code:
; CLIPBOARD CLEANER
; Converts the format of the clipboard to plain text and then pastes
; Faster than using Paste Special in most applications (e.g., Office)
; Especially useful to paste the text of filenames copied from Windows Explorer
; Shortcut key is Windows + v
#v::
clipboard=%clipboard%
Send ^v
return



Regards,

Martin O'Neill
Back to top
DaTex



Joined: 21 Nov 2006
Posts: 4
Location: Texas, USA

PostPosted: Wed Sep 09, 2009 3:55 pm    Post subject: Reply with quote

Martin,

What an obvious improvement - thank you. I can add the Win+V to the script so that you can "clean and paste" in one action, or "clean only" in case you want the clipboard text to be available to another script. I will update the script on the website.

DaTex
Back to top
View user's profile Send private message Visit poster's website
pajenn



Joined: 07 Feb 2009
Posts: 384

PostPosted: Sat Sep 19, 2009 12:24 pm    Post subject: Re: ClipCleaner Reply with quote

DaTex wrote:
2. If you need a list of filenames from an Explorer window, select the files and copy them to the clipboard. The file names are not available as ASCII text at this point, they are in a special format so that Windows can link to the files when you paste the names. But now if you WANT only the names, pressing Win+C will "clean" them up and convert them into their text equivalents (with full path names).


For users who also want the names of files (not full paths), you can trim lines on clipboard down to the last backslash with:
Code:
Clipboard := RegExReplace(Clipboard,"`am)^.*\\")
Back to top
View user's profile Send private message
LC
Guest





PostPosted: Wed Mar 03, 2010 9:29 pm    Post subject: Re: ClipCleaner Reply with quote

Quote:
Code:
Clipboard := RegExReplace(Clipboard,"`am)^.*\\")



pajenn, thanks for sharing. Your method requires fewer variables and is simpler to use then the ahk SplitPath Function. Your code will go into my RegEx Library.

I encourage everyone to share their RegEx scripts as pajenn did here. Great scripts like his help to shorten ahk scripts and the development time of them.
And, we all benefit from that!
Back to top
Maestr0



Joined: 18 Oct 2008
Posts: 159

PostPosted: Sun Mar 07, 2010 9:26 am    Post subject: Reply with quote

adding the following code will auto-clean the clipboard if it contains any text.

Code:
OnClipboardChange:   ; -- this automatically cleans all text on the clipboard from formatting, so ctrl-c and ctrl-v can be used
   if A_EventInfo = 1   ; -- 1 is text, 2 is a picture
      clipboard=%clipboard%
return


If it only contains a picture, the A_EventInfo will be 2. If it's a picture AND text, A_EventInfo will be 2.
Keeping that in mind, the original script can be enhanced with a simple if line:

Code:
#c::
   if A_EventInfo = 1   ; -- 1 is text, 2 is a picture
      clipboard=%clipboard%
return

#v::
if A_EventInfo = 1   ; -- 1 is text, 2 is a picture
   clipboard=%clipboard%
Send ^v
return
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Mon Mar 08, 2010 2:22 am    Post subject: Reply with quote

see similar ideas here
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group