Anyone who often works with texts and operates with such concepts as "number of characters" or "words" feels an urgent need for a text editor counter. Program Pages, Word, Byword and the like are equipped with such means. But do not skip the in-app any text fragment when you need to find out its size - it is not always convenient. To count characters, words, paragraphs and was always at hand, you can use the "Avtomatorom" by creating a very simple service in it.
Launch Automator and new processes in the list, select the type Service. From the outset, our future configure the service: the design surface in the header to select the top two drop-down box Text (text) and any application (any application)Respectively.
Now, from the sidebar, in the section Library> UtilitiesDrag to action designer Run AppleScript (Run AppleScript). The area code of this action will have a standard blank - replace it with the following code:
on run {input, parameters} try --Perevod text input array into a string format set MyText to input as string --Opredelenie and record variable number of characters, words, and paragraphs set CharactersNumber to the number of characters of MyText set WordsNumber to the number of words of MyText set ParagraphsNumber to the number of paragraphs of MyText --Formirovanie the appearance of the dialog box, set DialogIcon to ( "///System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ClippingText.icns") as POSIX file set DialogTitle to "The selected text fragment: "set ResultString to" Signs: "& CharactersNumber ¬ & return &" words: "& WordsNumber ¬ & return &" Subpoints: "& ParagraphsNumber --Otobrazhenie dialog box as defined above using terms from application "Finder" display dialog ResultString ¬ with icon DialogIcon ¬ buttons { "OK"} default button 1 ¬ with title DialogTitle end using terms from --Obrabotchik error situation on error errmsg number errnum display dialog errmsg & "[" & errnum & "]" ¬ buttons { "OK"} default button 1 with icon stop end try return input. end run
Actually, that's all. It remains only to keep the service under the name of, for example, Statistics and test it in practice - at least on the example of a web browser.
Download any web page with more or less surround the text, select an arbitrary fragment and click on the right mouse button - from the context menu should appear team Statistics (It may be the group services). By pressing it, you will see the result of service work - small dialozhek with the required information about the highlighted text: