Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A word count action script for Quicksilver Apps
Here's a simple AppleScript that I wrote that uses Growl to display the number of characters, words, and lines in a piece of text selected in Quicksilver (just copy and paste the code into Script Editor, and save in ~/Library » Application Support » Quicksilver » Actions).

Word/letter/line counting is a simple but useful function that I couldn't find anywhere else in Quicksilver, and it's is particularly useful for checking the length of Twitter updates before sending them using, for example, the Tweet action by Coda Hale, or this improved version with Growl support by Ted Leung. Thanks to Ted for the Growl notification part of the script that I adapted.

I hope people find this useful. Previously I'd echo my tweet through a pipe to wc and run as a shell command in Quicksilver to check the length. This action is a big improvement -- now Quicksilver provides my favourite way to update Twitter.

[robg adds: Note that any updates to the above-linked script will probably be posted in this thread on Quicksilver's forums. The one I linked to above is stored on just to insure that it's downloadable in the event something does happen to the original post. As of today (February 12th 2007), both versions are identical.]
  • Currently 2.50 / 5
  You rated: 3 / 5 (4 votes cast)

A word count action script for Quicksilver | 8 comments | Create New Account
Click here to return to the 'A word count action script for Quicksilver' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A word count action script for Quicksilver
Authored by: boredzo on Feb 12, '07 08:29:34AM

Another way is WordService, which offers a word count. Any service can be used from Quicksilver; you need only install the Services Menu Module from Quicksilver's plug-ins list.

Mac OS X Hints has a review of WordService.

[ Reply to This | # ]
A word count action script for Quicksilver
Authored by: NovaScotian on Feb 12, '07 11:54:06AM

Instructions followed - but the CountWords.scpt does not appear in the Actions pane of a QS query for a document even after quitting and restarting QS. More to the hint than was explained, apparently.

[ Reply to This | # ]
Same Problem, Step missing?
Authored by: NHN on Feb 13, '07 12:50:06AM

I can verify my predecessors comment, I also tried to put the script in my script folder which is also accessible via QS but it still does not show up. Rather sad since it seems such a useful hint. Thanks anyway, all things Quicksilver are always welcome!

[ Reply to This | # ]
A word count action script for Quicksilver
Authored by: thejoecarroll on Feb 13, '07 06:25:41AM

Apologies for not stating this: in order to for the action to show up in Quicksilver, it is apparently necessary to turn on "Scripts (All Users)" as well as "Scripts (User)" catalogs. It seems that Quicksilver doesn't always automatically pick up on scripts in the ~/Library/Application Support/Quicksilver/Actions/ folder.

Restarting Quicksilver after this made my action available, but this stopped working after a crash. I was able to fix this by manually adding the action to the Custom section of the Catalog preference pane (just drag and drop). Quicksilver is still beta software after all :-)

[ Reply to This | # ]
A word count action script for Quicksilver
Authored by: mono toto on Feb 14, '07 07:00:02AM
I came up with my own rendition from this. Doesn't require Growl and uses quicksilver's display large type (similar to the 'get IP' script that comes bundled).

To try it, you could just copy the script from the comment, get into the text editing mode of QS, paste and then choose 'run as applescript' as the action.

tell application "System Events" to tell (item 1 of (processes whose frontmost = true))
keystroke "c" using command down
delay 0.5
set str to (the clipboard)
tell application "Quicksilver" to show large type " Characters: " & (count characters of str) & "
Words: " & (count words of str) & "
Paragraphs: " & (count paragraphs of str)
end tell

To use it more permanently, just save this into a .scpt, select some text in a document and then (with the text still selected) fire up QS and get it to run the script.

Does anyone know of a better way to grab the selected text other than using the clipboard? Any other critique would also be welcome.

[ Reply to This | # ]
import selected text into quicksilver for faster counting
Authored by: NHN on Feb 15, '07 01:20:01PM

Hi everybody,
I would also find it extremely useful to set up a trigger which allows me to paste a selected text (for example a paragraph within a website) directly into quicksilvers first pane (which would then automatically be turned into text mode), switch over to the second pane and just initiate the word count action. Have I missed anything or is this possibility not integrated into the standard quicksilver action catalogue?

[ Reply to This | # ]
A word count action script for Quicksilver
Authored by: thejoecarroll on Feb 21, '07 04:58:42AM

Nice script, monototo. You're approaching the task from a slightly different angle and your offering would certainly be more useful than mine in some situations. Personally, I prefer Growl Notifications to the big text thing in Quicksilver. Although Quicksilver has its own Growl command in Applescript, I found the formating was coming out all wrong so I interfaced directly with Growl.

The only alternative I can think of is Quicksilver's proxy object "Current Selection". It should work, but certain features/catalogs need to be activated and it would probably be a good idea to check/convert the selection if it is not a piece of text.

[ Reply to This | # ]
A word count action script for Quicksilver
Authored by: Adriana on Mar 06, '12 05:27:56PM
Is there any way to skip Quicksilver altogether and have a Growl Notification that uses count (the clipboard) as an AppleScript?

I donīt know anything about coding but I managed to make a Script that counts the characters and made a Keyboard trigger. But it brings the Dialog Window in the background and I need to go back and check.

tell current application
display dialog (return & (count (the clipboard)))
end tell

I constantly have to check character length and I need something that does not disrupts my work flow. Copying the text and using the script works fine, except for having to leave my current Application in order to check the pop-up Dialog.

Any help will be greatly appreciated.

[ Reply to This | # ]