ReClip; a Text Reformatting and Clip Management Utility

Post your working scripts, libraries and tools for AHK v1.1 and older
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

ReClip; a Text Reformatting and Clip Management Utility

16 Feb 2017, 19:28

Introduction
ReClip uses the clipboard to perform a variety of different text reformatting tasks, and also includes clip management facilities. It was convenient to place these rather different roles in the same program so that Windows clipboard changes that were caused by the reformatting side, could be locked out of the clip management part of the program and not appear in the historical list of clips.

If you wish to only use some of the facilities of ReClip, just ignore the parts you're not interested in.

Reformat Text
This feature works in conjunction with any text editor, on selected text. It allows for a variety of different text formatting options, etc. Below is a summary of the options available. More detailed information is in the ReClip built-in help.
  • Mono-spaced text in selected paragraphs can be reformatted to fit within a fixed number of columns. Formatting options here include ragged right, justified, centred, or unformatted. (See the 'Change options' screen shot, and this post for an example.)
  • Selected lines of text can be examined for over-long lines, showing a report highlighting lines found.
  • A variety of different case-conversions may be performed on the selected text. (See the 'Extra facilities' screen shot. The algorithm used for capitalising sentences is described in this post.)
  • You can centre text within repeating characters on lines, with optional insertion of source code comment tokens at the start of each line.
  • Selected text can be wrapped within a duplicated character. For example if the selected text was 'word' (without the quotes) and the character was %, the replaced text would be %word%. The various brackets are handled intelligently. (Thanks to davebrny and guest3456 for the idea.)
The overall hotkey used by ReClip can be changed in the Extra facilities window (see the screen shot below), and defaults to CapsLock. It is used in various combinations with the Windows, Shift, Ctrl, and Alt keys to trigger the various activities.

In addition, right-clicking the system tray icon will give access to all ReClip's features. For touch screen friendliness you can also set a default item to be actioned by double (or single) clicking the tray icon.

As a safety measure, ReClip will also monitor the Control+Z hotkey when sent to Windows File Explorer. For further information on this see the 'Help' screen shot.

Screen shots:-

Clip Management

This feature is very light on resources used, and makes use of in-memory indexes to locate a particular clip or list of clips quickly. The normal Windows clipboard hotkeys and menu items work in the standard way and are not monitored by ReClip.

This facility is disabled by default. It can be turned on by entering a suitable number in the 'Extra facilities' => 'Alter Other settings' => 'Max number of temp clips' window item (see the screen shot above).

When there is a new clip in the Windows clipboard, ReClip records a copy, assigns a name to the clip, writes both to disk, and adds the name to the top of its main list. Any old same-named clip in the main list is deleted.

The clips in the main list are temporary and age down as new clips are recorded. However when one of these temporary clips is accessed, it is moved back to the top of the list. The clips at the bottom of the main list will be deleted when the total number exceeds the maximum defined by the user in the settings. (See the 'Other settings' section of the 'Extra facilities' screen shot above.)

In addition to the main list, you can create folders to hold permanent clips, and manage the clips in these folders. (In the screen shots below, the 'Kept', 'Special', etc. folders have been set up to demonstrate this feature.)

To see a menu of previous clips, press the appropriate hotkey, or select 'Access clips' from the ReClip tray menu. Paste a clip via the clipboard by left-clicking with the mouse, or right-click to see an additional menu for managing this clip.

To help find a particular clip, you can specify a simple filter by clicking on the menu header. The list shown will then only include clips which contain that filter in the name.

For more information, see the ReClip built-in help.

Clipboard monitoring can be switched off (and on) from a separate script if it is required to use the clipboard for a while without ReClip saving the contents. Use code like this:

Code: Select all

DetectHiddenWindows On
PostMessage 4321, 2,,, ahk_exe ReClip.exe  ; Turns off ReClip clipboard monitoring
MsgBox Clipboard monitoring is off

PostMessage 4321, 0,,, ahk_exe ReClip.exe  ; Turns on ReClip clipboard monitoring
MsgBox Clipboard monitoring is on
DetectHiddenWindows Off
Note that the code for turning monitoring off should be matched with code to turn monitoring on again in a one-to-one relationship.

Screen shots:-

Download
ReClip can be downloaded from here. The zip file includes source, executable, and preferred icon.

Update History (latest first)
Last edited by TAC109 on 18 Jan 2023, 16:20, edited 19 times in total.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Feb 2017, 17:19

I find the reformatting very useful, eg

Code: Select all

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis sed bibendum eget, fringilla id dui. Nulla ultricies tempor magna, quis dictum urna vehicula eget. Praesent sed lorem nec nisi aliquam maximus. Cras sem orci, rhoncus sed dui at, fringilla dictum risus. Cras mattis ante et ex malesuada vehicula. Cras lobortis mi sed mi lobortis porta. Curabitur rhoncus, ante ut dictum pretium, leo elit ullamcorper ante, quis condimentum velit nisi at nibh. Curabitur sem risus, convallis at eros dapibus, fringilla vehicula velit. Suspendisse quis convallis mi.
to

Code: Select all

Lorem ipsum dolor sit  amet,  consectetur  adipiscing  elit.  Etiam  scelerisque
 maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros,
 facilisis  sed  bibendum  eget, fringilla id dui. Nulla ultricies tempor magna,
 quis dictum urna vehicula eget. Praesent sed lorem nec  nisi  aliquam  maximus.
 Cras  sem orci, rhoncus sed dui at, fringilla dictum risus. Cras mattis ante et
 ex malesuada vehicula. Cras  lobortis  mi  sed  mi  lobortis  porta.  Curabitur
 rhoncus,  ante  ut  dictum pretium, leo elit ullamcorper ante, quis condimentum
 velit nisi at nibh. Curabitur sem risus, convallis at eros  dapibus,  fringilla
 vehicula velit. Suspendisse quis convallis mi.

Is there a hotkey for invoking the Extras? Eg capitalise sentence.
I get a question I don't understand when capitalising sentences.
capsentence.png
capsentence.png (3.77 KiB) Viewed 11561 times
I press yes and the sentence is capitalised just fine.

Very good job, thanks for sharing! :thumbup:
guest3456
Posts: 3453
Joined: 09 Oct 2013, 10:31

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Feb 2017, 17:40

Some editors (Vim) can do a lot of these reformatting features built-in. But I understand not everyone wants to learn new stuff ;)

TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Feb 2017, 18:12

@helgef Thanks for your kind words - I'm pleased you're finding ReClip useful.

To use item on the 'Extras' window you need to first select your text, then use the 'Extras' hotkey (or select from the tray menu), then choose the required radio button, then press ok. It seemed impractical to assign a different hot key to each of the 7 options. You can select items on the 'Extras' window by accelerator key (on many systems you need to hold the 'alt' key to see them). (Items on all ReClip windows and menus can be selected by an accelerator key, except tray items.)

Regarding the 'Capitalise sentence' prompt; after much research (googling) when writing this code, I determined that it is apparently very difficult to accurately predict the start of a sentence. In the end I coded a relatively simple algorithm which detects the end of a sentence by looking for ? ! or . followed by white-space, ignoring any other special characters. If the next character is lower case, the code shows the 'Capitalise sentence' confirmation prompt. (This prompt is also displayed for the start of the selected text in case the user's selection was not at a sentence start.)

An example of a difficult phrase is I visited the Dr. and he prescribed some medicine. In this case, the algorithm would incorrectly select the 'a' of 'and' as a candidate for capitalisation.

So the code prompts in each case to confirm whether the 'double dagger' is at a sentence break before optionally capitalising the next character.

Thanks again for trying ReClip.

[Edited 'Capitalise sentence' information for clarity]
Last edited by TAC109 on 11 Jul 2017, 22:33, edited 6 times in total.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Feb 2017, 18:47

I found !#CapsLock opens the extras menu, that is satisfactory. I cannot remember many hotkeys anyways :shock:
I disabled the mb for the capitalise sentence.

Cheers!
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Feb 2017, 20:01

That's fine. This option was designed to work on a large block of text containing a number of sentences, and where you may not have started your selection at a sentence start.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

18 Mar 2017, 17:16

19 March 2017 - Updated download link.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

07 May 2017, 11:01

Is/would it be possible to format source code commented text such that, eg

Code: Select all

; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
; sed bibendum eget, fringilla id dui. Nulla ultricies tempor magna, quis dictum urna vehicula eget. Praesent sed lorem nec nisi aliquam maximus. Cras sem orci, rhoncus sed dui at, 
; fringilla dictum risus. Cras mattis ante et ex malesuada vehicula. Cras lobortis mi sed mi lobortis porta. Curabitur rhoncus, ante ut dictum pretium, leo elit ullamcorper
; ante, quis condimentum velit nisi at nibh. Curabitur sem risus, convallis at eros dapibus, fringilla vehicula velit. Suspendisse quis convallis mi.
would become,

Code: Select all

; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque
; maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros,
; facilisis sed bibendum eget, fringilla id dui. Nulla ultricies tempor magna,
; quis dictum urna vehicula eget. Praesent sed lorem nec nisi aliquam maximus.
; Cras sem orci, rhoncus sed dui at,  fringilla dictum risus. Cras mattis ante et
; ex malesuada vehicula. Cras lobortis mi sed mi lobortis porta. Curabitur
; rhoncus, ante ut dictum pretium, leo elit ullamcorper  ante, quis condimentum
; velit nisi at nibh. Curabitur sem risus, convallis at eros dapibus, fringilla
; vehicula velit. Suspendisse quis convallis mi.
Note that there is no ; inside the new text. Sorry for being lazy ;)

Cheers.
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

07 May 2017, 18:38

No need to apologise :)

Actually, that facility has already been provided for (if I understand you correctly).

If you look at the 'Change options' window (default hotkey Window+Ctrl+Capslock), there is a 'Data at left to skip' field. If you insert in there '; ' (i.e. semicolon followed by space), this should achieve what you want.

In more detail:- The contents of this field will be removed from the start of reformatted lines before reformatting, if present. Then after the reformat has taken place the contents of this field are placed at the start of each newly formatted line. (The resulting line will be no longer than defined in the 'Max number of columns' field defined in the same window.) If the second line of the original text has the same indent as the first line, as it does in your example text, then the output text will line up the same. (This is true for all text reformatted by this function.)

I've tried to document this in the help pages; please let me know if this needs clarification. I find that it is often difficult to create a clear description of code that I am too familiar with.

Thanks for using ReClip.

(Edited reply to be more exact.)
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

08 May 2017, 10:04

Awsome! Thanks :dance:
I find that it is often difficult to create a clear description of code that I am too familiar with.
+1
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

08 May 2017, 10:18

Slight problem, consider this,

Code: Select all

; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
I get:

Code: Select all

; Lorem ipsum dolor sit amet, consectetur  adipiscing  elit.  Etiam  scelerisque
; maximus  laoreet.  Morbi  in  feugiat  metus. Donec ut congue ligula. Cras dui
; eros, facilisis Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam
; scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut  congue  ligula.
; Cras dui eros, facilisis
Perfect!, but when the comment is indented, like this,

Code: Select all

	; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
	; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam scelerisque maximus laoreet. Morbi in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
i get

Code: Select all

;        ; Lorem ipsum  dolor  sit  amet,  consectetur  adipiscing  elit.  Etiam
;        scelerisque  maximus  laoreet.  Morbi in feugiat metus. Donec ut congue
;        ligula. Cras  dui  eros,  facilisis  ;  Lorem  ipsum  dolor  sit  amet,
;        consectetur  adipiscing  elit. Etiam scelerisque maximus laoreet. Morbi
;        in feugiat metus. Donec ut congue ligula. Cras dui eros, facilisis
I am useing these settings,
reclipComment.png
reclipComment.png (30.21 KiB) Viewed 11084 times
Edit: I work around by alt+select in notepad++, main place of usage anyways.
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

08 May 2017, 16:55

Yes, if you include the 4 leading spaces in the 'data at left to skip' field it will work as expected.

I guess my comment about indent in my previous post is over-simplified. :oops:

In fact the rules about indents are applied after the 'data at left to skip' field has been removed from the start of line(s), if present. The newly reformatted data (with indents) will then have the 'data at left to skip' field inserted at the start of each line.

Hope this is usable for you.

[Edited for clarity]
Last edited by TAC109 on 11 Jul 2017, 21:41, edited 2 times in total.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: ReClip; a Text Reformatting and Clip Management Utility

08 May 2017, 17:09

TAC109 wrote: Hope this is usable for you.
; Thank you for taking the time to explain. It is very useful, I've used
; it several times today already, I'm just irritated I didn't realise this
; feature was available earlier.

Cheers :D
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

22 Jul 2017, 22:37

Update 23 July 2017 -
  • Enhanced tray menu access to be more touch screen friendly.
  • The 'wrap text' facility will now detect the error condition 'nothing selected' immediately.
  • Updated the ReClip icon.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

07 Sep 2017, 20:31

Updated 8 September 2017 -
Fixed the formatting of some windows when screen DPI was other than 96.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

14 Sep 2020, 00:01

The following text has been added to the first page of this thread.
Warning: the Clip Management feature is not working correctly with AutoHotkey versions 1.1.33.00, 1.1.33.01, and 1.1.33.02, in that right-clicks on the clips menu are not recognised correctly. If you wish to change the source it is recommended to compile with a Unicode 32-bit.bin file from an earlier version of AutoHotkey. A bug report for AutoHotkey has been filed. The included ReClip.exe works correctly as it was compiled with an earlier version of AutoHotkey.
Edit: Now removed as at 16 November 2020.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

15 Nov 2020, 21:46

16 November 2020 -
Fixed clip management right-click menu, which stopped working in AutoHotkey v1.1.33.00 - 1.1.33.02.

See this post for download details.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
HuckD
Posts: 7
Joined: 16 Feb 2021, 15:27

Re: ReClip; a Text Reformatting and Clip Management Utility

25 Mar 2021, 11:08

When I download ReClip.zip the file gets quarantined by MalwareBytes. Supposedly it contains a trojan virus. Is this a known problem?
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: ReClip; a Text Reformatting and Clip Management Utility

25 Mar 2021, 11:41

HuckD wrote:
25 Mar 2021, 11:08
When I download ReClip.zip the file gets quarantined by MalwareBytes. Supposedly it contains a trojan virus. Is this a known problem?
Can't explicitly speak for ReClip, but false positives for AHK scripts (compiled or uncompiled) are a well-known problem, yes.
TAC109
Posts: 1096
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: ReClip; a Text Reformatting and Clip Management Utility

25 Mar 2021, 21:41

ReClip is quite safe to use and does not contain any viruses. All it does is as described in the first post of this thread, and the source is also included in the .zip for inspection. You could help by reporting this as a false positive to MalwareBytes.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 73 guests