Counting characters in a segment

I came across this script from Selcuk Akyuz in the Proz website a few weeks ago:

;------------------------------------------------------------------------------
; Count characters in a segment
;------------------------------------------------------------------------------
!c::
Send, ^c
ClipWait
Chars := StrLen(Clipboard)
RegExReplace(Clipboard,A_Space,"",Spaces)
MsgBox % "The highlighted text is " Chars " characters in length and contains " Spaces " spaces."
clipboard = ; Empty the clipboard
return

The way it works is you select some text in the source or target segment and press Alt+c.  You then get something like this with a small message box that contains the count including spaces:

Paul Filkin | RWS Group

________________________
Design your own training!

You've done the courses and still need to go a little further, or still not clear? 
Tell us what you need in our Community Solutions Hub

Parents Reply Children
  • Hi Paul,

    I have a problem with this script. I think it needs some way to reset it, although I have no idea how. If I select a three-character word after having run the script, say, for a 10-character selection, the message box says the new selection, which I plainly see has only 3 characters, has 10 characters, in other words, the previous result seems to remain in the clipboard and is output again after a new selection and new press of the hotkey.

  • Hi Nora,

    ok - I amended it as I also had the same issue when I repeat it like this. So I added:

    Clipboard =

    This just clears the clipboard.

    That works for me now flawlessly. I'll update the script above in case someone else takes it.

    Regards

    Paul

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub