Search code examples
autohotkey

Text character counting functionality in ahk v1


Is there any text counting functionality in ahk?

I want to make an character counter where, if I press Ctrl+Alt+-, an InputBox will open up. The input's length would be counted, and would be returned to the user, in the form of a MsgBox.

Currently, I have:

<^<!-::
InputBox, Text1, Count, Paste the text in the text box to count the number of characters it has, and find things in that text
MsgBox text:You typed %Text1%.`nCharacters:
return

Solution

  • The StrLen() function retrieves the count of how many characters are in a string.

    <^<!-::
        InputBox, Text1, Count, Paste the text in the text box to count the number of characters it has, and find things in that text
        if ErrorLevel
            return
        number_of_chars := StrLen(Text1)
        MsgBox text:You typed %Text1%.`nCharacters:%number_of_chars%
    return