Skip to content

Instantly share code, notes, and snippets.

@corelon
Created March 4, 2014 21:09
Show Gist options
  • Save corelon/9355684 to your computer and use it in GitHub Desktop.
Save corelon/9355684 to your computer and use it in GitHub Desktop.

Revisions

  1. Noah Slater created this gist Jan 15, 2012.
    19 changes: 19 additions & 0 deletions Word and Character Count.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # Word and Character Count service for Mac OS X
    #
    # Adds a Word and Character Count option to the text selection context menu in all apps
    #
    # Use Automator.app to create a new service, and then select the Run AppleScript action.
    # Paste this code in to the text box, and save as Word and Character Count. Now switch to
    # a new app, select some text, and open the context menu to find the new option.

    on run {input, parameters}
    tell application "System Events"
    set _appname to name of first process whose frontmost is true
    end tell
    set word_count to count words of (input as string)
    set character_count to count characters of (input as string)
    tell application _appname
    display alert "" & word_count & " words, " & character_count & " characters"
    end tell
    return input
    end run