AutoHotkey Community

It is currently May 26th, 2012, 10:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: ClipCleaner
PostPosted: September 8th, 2009, 4:15 pm 
Offline

Joined: November 21st, 2006, 4:51 pm
Posts: 4
Location: Texas, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2009, 10:27 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2009, 4:55 pm 
Offline

Joined: November 21st, 2006, 4:51 pm
Posts: 4
Location: Texas, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ClipCleaner
PostPosted: September 19th, 2009, 1:24 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
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)^.*\")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ClipCleaner
PostPosted: March 3rd, 2010, 10:29 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2010, 10:26 am 
Offline
User avatar

Joined: October 18th, 2008, 2:09 pm
Posts: 426
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 3:22 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
see similar ideas here


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Cristi®, jrav and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group