[AHK v2] Compare Texts and Highlight Differences

Post your working scripts, libraries and tools
oif2003
Posts: 160
Joined: 17 Oct 2018, 11:43
GitHub: oif2003

[AHK v2] Compare Texts and Highlight Differences

12 Nov 2018, 23:24

Hi,

I made a script that compares two texts and highlights the differences (red - deletion, green - insertion). It first computes the longest common subsequence between the two texts in the user chosen mode (line, word, or character), then it outputs the results by highlighting the differences in the RichEdit boxes. Highlighted portions of the results and the LCS (longest common subsequence) can be copied to clipboard with the option of using `r`n as extra delimiters. It gives correct, but annoying results when text is repeated (more prone to happening in character comparison mode). Use at your own risk!

To test it out you will need the following files:
https://github.com/oif2003/RichEditBox/ ... e.ahk?ts=4
https://github.com/oif2003/RichEditBox/ ... t.ahk?ts=4

credit: Just Me, majkinetor, corrupt, jballi, DigiDon, and burque505 for Class_RichEdit

Edit: The script now consolidates changes that are adjacent or can be made adjacent through swapping of matched characters in different positions. This partially fixes the annoying issue of fragmented results on text that has many repeating parts.
Attachments
textComparisonSS2.png
textComparisonSS2.png (78.55 KiB) Viewed 244 times
Last edited by oif2003 on 14 Nov 2018, 20:15, edited 2 times in total.
burque505
Posts: 685
Joined: 22 Jan 2017, 19:37

Re: [AHK v2] Text Comparison With Difference Highlighting

13 Nov 2018, 12:12

@oif2003, that's very nice, and I like what you've done with Class_RichEdit for v2. Thanks for sharing it.
Regards,
burque505

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 46 guests