topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 4:12 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Autoreplace in clipboard  (Read 22140 times)

Jabberwock

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 76
    • View Profile
    • Donate to Member
Autoreplace in clipboard
« on: October 07, 2007, 02:50 PM »
I have read some "clipboard tool" forums, but have not found an answer to my question...

That is: is there a freeware app that would replace the text in the clipboard with something else? It would be nice if it did just that, I am not in need of a bloated clipboard manager. Ease of adding of new entries and flexibility (regexp?) would be an added benefit...

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #1 on: October 07, 2007, 03:10 PM »
I don't understand what you are asking for. :huh: Replace the contents of the clipboard with what? How would it know what to replace it with? Can you provide a few examples please?

Jabberwock

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 76
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #2 on: October 07, 2007, 03:19 PM »
Sorry...

An example:

I copy text "this is rather uncorrect" to the clipboard. The app is watching the clipboard, checks it against its configured list of replacements, finds out that I want every occurence of "uncorrect" to be "incorrect" and makes the substitution. The clipboard now holds the text "this is rather incorrect". You might compare it with Word's AutoCorrect, but done on clipboard, not on typed text.

JaneDC

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 36
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #3 on: October 07, 2007, 03:56 PM »
you can do this with autohotkey. youll have to provide more details though.

Jabberwock

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 76
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #4 on: October 07, 2007, 04:27 PM »
Hmm... I missed the fact that AHK has the ClipWait function...

In that case it should be pretty simple: read up the values with IniRead to an array, wait for the clip and loop the array with the RegExReplace... I will have to try that out.

TucknDar

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,133
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #5 on: October 07, 2007, 04:43 PM »
you could even use this AutoCorrect AHK script to check and "fix" the clip: http://www.autohotke...load/AutoCorrect.ahk

This sounds like something mouser's Clipboard Help+Spell is designed to do, though. But I don't think it (currently) has this feature

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #6 on: October 07, 2007, 05:09 PM »
This sounds like something mouser's Clipboard Help+Spell is designed to do, though. But I don't think it (currently) has this feature

Not running CHS on this computer, so can't check - but CHS allows you to add your own filters, so you could use something like a SED script or one of the command-line search and replace tools.  This won't be completely seamless, as the OP seems to want.  You'd have to pop up CHS's main window and choose the filter, but, that method allows you as many search and replace pairs as you want.

If you want seamless, take a look at Clippy - you need the beta - one of its operations is given as


Name: Search and replace
Description: Replaces all occurrences of a string with another string.
Number in ini file: 28
Parameters: search string, replace string

Don't know if that's only one string or whether you can define multiple strings.

Boxer Software's TextMonkey is in similar vein, but more powerful; it comes in both payware and cut-down freeware versions.  Search and replace is a built-in function.  It allows up to four search-and-replace pairs.


lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #7 on: October 07, 2007, 08:44 PM »
as mentioned earlier, this can be done in Autohotkey, here is a sample..

Clipboard cleaner


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #8 on: October 08, 2007, 08:46 AM »
rjbull hit the nail on the head with CHS method, just in case you are interested:
  • CHS doesn't have a way to auto-apply formatting every time you copy something to clipboard per se, BUT you can do it all in one step!  Just select the text in question and then trigger the text formatting preset (rather than copy first) -- see more detailed instructions below.
  • But what it will do is let you create+configure a whole bunch of different custom search+replace/reformat/etc presets and show them on a quick pop-up menu for you to apply to text you have just captured while you paste it.
  • It comes with some of these text formatting presets that do things like convert the case of the text just copied.

How to use text-formatting preset in quickest way:
  • Select the text in question wherever it is
  • Bring up quick-popup menu in CHS (ctrl+alt+Q by default)
  • Choose the Text Formatting preset submenu (hit T)
  • Choose the text formatting preset to apply (you can create your own ones from the CHS main window)
  • Text will be copied, formatted, and pasted back

This "one-step" process is actually very useful in doing things like converting a line of text from one case to another, etc.
« Last Edit: October 08, 2007, 08:51 AM by mouser »

Jabberwock

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 76
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #9 on: October 08, 2007, 08:51 AM »
Thanks for the tips...

For now I am trying out Clippy, which work fine except two minor details (no regexp and you have to hit a shortcut to change, which is sometimes bad, but sometimes good...).

When I have more time I'll try the AHK script I have described.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #10 on: October 08, 2007, 11:12 AM »
This "one-step" process is actually very useful in doing things like converting a line of text from one case to another, etc.

It certainly is useful, especially with both recent and favorite clips in sub-folders, which largely obviates the need to open the text-processing sub-menu.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #11 on: October 09, 2007, 05:36 AM »
  • CHS doesn't have a way to auto-apply formatting every time you copy something to clipboard per se, BUT you can do it all in one step!  Just select the text in question and then trigger the text formatting preset (rather than copy first) -- see more detailed instructions below.
  • But what it will do is let you create+configure a whole bunch of different custom search+replace/reformat/etc presets and show them on a quick pop-up menu for you to apply to text you have just captured while you paste it.
  • It comes with some of these text formatting presets that do things like convert the case of the text just copied.

Mouser,

CHS comes with a rich set of features for twiddling text, especially if you want to clean up e-mails etc.  But it only has a single search-and-replace slot, so you can only change one string per preset, and you can't add external user-defined tools to a preset, as far as I can see.  Is that right?  That's what I was after in this thread: Configuring CHS user tools

At that time I was trying to use A. Pipkin's "Ministry of Truth" utility (developed on Linux, I suspect), and couldn't get it to work because it doesn't understand Windows LFNs properly - pity, because it's powerful and otherwise works well:
MiniTrue home page
MiniTrue enthusiast: Eric Pement's SED page - scroll down to Console/command-line apps
On no account overlook Eric Pement's supplementary tricks and traps page

Unable to make MiniTrue work properly, I changed to a SED script... but it would be much more useful if it could be incorporated into a CHS preset.  Currently, I've just put the same SED script into TED Notepad as a user-defined text filter.


blackcat

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 62
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #12 on: October 09, 2007, 05:45 AM »
@Jabberwock

what about HovText

HovText is a small freeware and open source Windows application that removes any formatting from the clipboard and it also works as a simple clipboard manager. Any text in the clipboard will be pasted as raw text without any HTML code, font size, color or layout etc. HovText remembers also the last 10 copied texts (both formatted and unformatted) and you can filter out whatever text you need with regular expressions.

screenshots
http://hovklan.com/d...mages/en_options.png
http://hovklan.com/d...mages/en_history.png
http://hovklan.com/d...mages/en_filters.png


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #13 on: October 09, 2007, 10:17 AM »
rjbull:
  • i should add some extra search and replace slots shouldn't i? i'll put it on my todo list.
  • are you saying the external tools configuration is still not working for you, or you are wanting to do something else besides what the current system is designed to do?

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #14 on: October 10, 2007, 09:25 AM »
i should add some extra search and replace slots shouldn't i? i'll put it on my todo list.

Thanks!    :Thmbsup:

are you saying the external tools configuration is still not working for you,

The external tools configuration is working for me - once I picked the right tool   :mad:  Maybe I'm not good enough to get MTR (32-bit version of MiniTrue) to work here, or maybe its LFN handling is too restricted.

or you are wanting to do something else besides what the current system is designed to do?

In a way, yes.  I'd like to be able to add external tools to the Formatting Presets menu on the pop-up, which doesn't seem to be currently possible.

Are you aware of the following:

  • It seems impossible to delete a formatting preset.
  • CHS has two rather different uses of the word "Preset" - one in the sense used here, and another from the main menu, where it means the appearance of the main window.




rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #15 on: October 10, 2007, 10:25 AM »
That is: is there a freeware app that would replace the text in the clipboard with something else? It would be nice if it did just that, I am not in need of a bloated clipboard manager. Ease of adding of new entries and flexibility (regexp?) would be an added benefit...

Jabberwock,

I just confected a possible solution - but you may not like it, and some assembly required.

  • Download ClipText from Horst Schaeffer's Web site, from the 32-bit Windows command-line tools section.
  • Install this batch file somewhere on your system:
    @echo off
    for %%a in (1 2) do if exist c:\temp\cliptext.%%a del c:\temp\cliptext.%%a > nul
    c:\dos\utils\cliptext.exe to c:\temp\cliptext.1
    c:\dos\utils\sed-359.exe -f c:\pcw\spellchk\chs.sed < c:\temp\cliptext.1 > c:\temp\cliptext.2
    c:\dos\utils\cliptext.exe from c:\temp\cliptext.2
    for %%a in (1 2) do if exist c:\temp\cliptext.%%a del c:\temp\cliptext.%%a > nul
  • Adjust paths as necessary.  Make a shortcut to it, and assign a hotkey.  I couldn't get this to work by assigning a shortcut in Windows itself, so I used PowerPro instead, which gives a wider choice of hotkeys, and allows you to set things to run hidden.  You may have your own favourite hotkey program.
  • Clip your text, press hotkey, press Ctrl-V...

I used SED 3.59 because it too is a 32-bit command-line tool, and being a version of SED, uses regular expressions.  You can get a copy from Eric Pement's SED page

I admit "ease of adding new entries" is not so seamless, but suggest you assign your search-replace file, CHS.SED in the example above, as a favourite file in your editor.  I mostly use TED Notepad for this kind of thing (I prefer my old WordStar-style DOS editor, VDE, for text-bashing, but that's another story).



mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #16 on: October 10, 2007, 10:47 AM »
rj, i was thinking i could enhance the formatting preset sytem and solve the problem you point out as well by doing this:
Add an option WITHIN the existing formatting presets to invoke a tool on the clip text IN ADDITION to performing the formatting options specified.

that is, right now you can either use an external tool, OR use the built-in system.  but what if i add running a tool to the choices of things you can do normally in a formatting preset.  this would let you add them to the pop-up menu like any normal formatting preset, and make it easier to combine both the built in functions with external tools.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #17 on: October 11, 2007, 03:14 AM »
what if i add running a tool to the choices of things you can do normally in a formatting preset.

Not sure I fully understand you, but to the extent that I do, yes, that sounds good.  Thanks!  :)


cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #18 on: October 11, 2007, 01:31 PM »
what if i add running a tool to the choices of things you can do normally in a formatting preset

Sounds good to me, also. If the preset performs no other action, then you have the external tool only.  In a sense, there's an inbuilt three-way switch; preset, tool, both.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #19 on: October 11, 2007, 01:46 PM »
exactly.

WhiteLion

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 43
    • View Profile
    • Donate to Member
Re: Autoreplace in clipboard
« Reply #20 on: October 18, 2007, 12:44 AM »
Spell check & correct contents of Windows clipboard.

You need to have Word 97 or higher installed. To use copy text to clipboard & click on the script. After corrections are complete you can paste the corrected text back to the original or another document.

Copy the following script below and paste it to a new blank .txt file then rename it to Spellcheck.vbs



WScript.Echo(SpellCheck())

Function SpellCheck()
  'compatibility check
  On Error Resume Next
  Set oWord = CreateObject("Word.Application")
  If Err Then
    SpellCheck = "Your system does not support Spell Check." & vbcrlf & _
                 vbcrlf & "You must have Microsoft Word 97 or higher " & _
                 "installed to enable this feature."
    Exit Function
  End If
  On Error GoTo 0
  With oWord
    .Visible = false
    Set spellDoc = .Documents.Add
    'trap errors for empty or invalid clipboard contents
    On Error Resume Next
    .Selection.Paste
    If Err Then
      spellDoc.Close
      .Quit
      SpellCheck = "Unable to spell check current clipboard contents." & _
                   vbcrlf & vbcrlf & "Highlight text selection to spell " & _
                   "check, use Ctrl + C" & vbcrlf & "to copy it to " & _
                   "clipboard, then click the Spell Check button."
      Exit Function
    End If
    On Error GoTo 0
    strIn = spellDoc.Content.Text
    spellDoc.CheckSpelling()
'   spellDoc.CheckGrammar()
    strOut = spellDoc.Content.Text
    If strIn = strOut Then
      results = "No spelling corrections made."
    Else
      results = "Spelling corrections copied to clipboard."
    End If
    .Selection.WholeStory
    .Selection.Copy
    spellDoc.Close False
    .Quit True
  End With
  SpellCheck = results
End Function