Notice: Mac OS X Hints is now a read-only site

We respect its storied history, and value the contributions of its many readers, but we can no longer support it at the level it deserves. There’s a wealth of great information here that many will find useful, so we’ve elected to maintain it in a read-only form. Thanks for your many years of attention and everything you’ve done to make the site such a valuable resource.

Source: Mac OSX Hints


Use AppleScript to count words and characters in text

[Original Article: Use AppleScript to count words and characters in text • comment by: robleach]
Just did this for any selected text (without having to copy)…set debug to false

–Get the highlighted text
set selecTxt to getHighlight(debug)

set myCount to count (selecTxt)
set myWords to count words of (selecTxt)
set myParas to count paragraphs of (selecTxt)

display dialog “Characters: ” & myCount & ”
Words: ” & myWords & ”
Paragraphs: ” & myParas

on getHighlight(debug)

–Save the current contents of the clipboard
set theSpare to the clipboard as record
–Save a text version of the contents of the clipboard if possible
set spareTest to “”
set spareTest to the clipboard as text
end try
–Declare the variable we’re going to return
set selecTxt to “”

tell application “System Events”
–Initiate the copy
keystroke “c” using {command down}

–Wait up to 2 seconds for the copy to finish
set done to “no”
set waitnum to 0
set waitInterval to 0.02
set maxwaits to 100

–Repeat while the clipboard contents have not changed
repeat while done = “no”
–Get the contents of the clipboard
set selecTxt to the clipboard as text

–See if we’re done or need to wait
if waitnum is equal to maxwaits then
set done to “yes”
else if spareTest is equal to selecTxt then
delay waitInterval
set waitnum to waitnum + 1
set done to “yes”
end if

end repeat

if debug is true then
display dialog “Copied text: ” & (the clipboard as text)
end if
end tell

–Restore the original clipboard contents
set the clipboard to theSpare as record

–Return the highlighted text
return selecTxt

end getHighlight

Source: Mac OSX Hints


Time to close the site

[Original Article: Getting Java client apps to run the way you want • comment by: rbenezra]
Been a fan for years but taking this one off my bookmark list for now. No one seems to care anymore, it’s been 1.5 months since the last published hint and many similar breaks for awhile now. Rob G where are you when we need you? Hopefully doing what you do best. Adios MOs …

Source: Mac OSX Hints