Archive for the ‘TextExpander’ Category

Random TextExpander Snippets Made Easy

Saturday, December 3rd, 2011

We regularly get requests for a way to choose a random snippet from among a set of snippets. To date, we’ve pointed folks to this technique:

http://nerdgap.com/how-to-randomly-selected-snippets-in-textexpander/

Now that TextExpander itself is AppleScriptable (as of version 3.3), there’s an easier and more flexible way to do this:

  1. Choose File -> New Group
  2. Name the new group Random
  3. Add snippets that you’d like to be chosen at random into the Random group. You can drag existing snippets from other groups into Random, or you can create snippets expressly for use in Random.
    Tip: if you are creating new snippets for use only as random snippets, you can save time and work by not assigning abbreviations to these snippets.
  4. Make a new snippet in a group other than the Random group
  5. Set the Content: of the new snippet to AppleScript
  6. Enter this for the snippet:
    tell application "TextExpander"
    	set groupCount to count (snippets of group "Random")
    	set randomIndex to random number from 1 to groupCount
    	return plain text expansion of ¬
    		snippet randomIndex of group "Random"
    end tell
  7. Set an abbreviation for this new snippet, for example: rrand

Any time you type rrand, you’ll get a random selection from among the snippets in your Random group.

The advantages of this technique over the one linked above are:

  • You need not know the abbreviations for all of the snippets in advance
  • You can add to and remove from your Random group without changing anything

(Thanks to Sheree Peña of Black Pixel for the inspiration for this post.)

Fix Dock Hiding for TextExpander 3.3 on the Mac App Store

Thursday, May 12th, 2011

If you prefer to hide the TextExpander icon in the Dock, then you ran into trouble when you updated TextExpander to version 3.3 on the Mac App Store. We’re sorry for the trouble. We made a mistake by checking the wrong box when updating TextExpander’s version number for the Mac App Store. Fortunately, this mistake is easy to correct. Here’s how:

  • Quit TextExpander if it is running.
  • Download the “Fix TextExpander 3.3.zip” file.
  • Double-click to expand the file to “Fix TextExpander 3.3.scpt”
  • Double-click “Fix TextExpander 3.3.scpt” to load it into AppleScript Editor
  • Press Run
  • After the script completes, launch TextExpander (and quit AppleScript Editor)

Our apologies for the inconvenience. This will be fixed in our next update.

Note: After running this script, it may appear that TextExpander is not installed in the Purchased section of the App Store application. If you Install at the next update, that will no longer be an issue.

Update, 5/20/2011: An update with the fix is now available on the Mac App Store. Thanks for your patience.

AppleScript and Shell Script Snippet Issues in TextExpander 3.3

Monday, April 25th, 2011

A couple of unfortunate issues have cropped up in the recently-released TextExpander 3.3. We wanted to make you aware of them and offer workarounds.

AppleScript Snippets
If you create a new snippet and set it to AppleScript, TextExpander 3.3 still treats the new snippet as a text snippet. When you expand it, the result will be the content of the AppleScript, not the script results. Any AppleScript snippets you created in earlier versions are still treated as AppleScript snippets.

As a workaround, you can duplicate an existing AppleScript snippet and then edit its contents.

Apple Script and Shell Script Snippets and “%”
This issue with shell script and AppleScript snippets involves the % (percent) symbol. TextExpander has always used % to delimit macros. In a script snippet,  TextExpander 3.3 is treating the % as a macro delimiter, which allows you to embed snippets within script snippet source code, but this has the unfortunate side effect of misinterpreting occurrences of ‘%’ as a character.

One workaround is to use 2 percentage signs (%%) to “escape” the % character (TextExpander power user @drdrang posted more about this on his blog), but this is inconvenient and does not work if the script snippet itself is embedded within another snippet.

If you use script snippets a good deal, you may want to consider reverting back to TextExpander 3.2.4. We do apologize for the aggravation and we hope to release a fix shortly in TextExpander 3.3.1.

AppleScripting TextExpander

Tuesday, April 19th, 2011

TextExpander version 3.3 [download] introduces AppleScript support, primarily oriented toward automating snippet and group management. TextExpander includes AppleScript support for:

  • creating and deleting groups
  • editing group properties
  • creating and deleting snippets
  • editing snippet properties
  • adding (importing) groups from files or from URLs
  • enabling/disabling expansion

These capabilities should be broad enough to allow for some interesting scripts to be created. As you develop scripts, you may encounter some limitations. Your feedback will help determine future expansion of TextExpander’s AppleScript vocabulary.

Here are a couple of sample scripts to get you started. The first one creates a new group and then creates two snippets within it:

tell application “TextExpander”

–– create a new group

make new group with properties {name:”My New Script Group”}

set newGroup to the result

tell newGroup

–– create a snippet, then set the major properties one by one

make new snippet

set newSnippet to the result

set the abbreviation of newSnippet to “tastytreat”

set the plain text expansion of newSnippet to “Toasted marshmallows are a tasty treat”

set the label of newSnippet to “Snippet from AppleScript”

–– create a snippet, setting properties immediately

make new snippet with properties {label:”Second Scripted Snippet”, abbreviation:”scrptwo”, plain text expansion:”Eat Two Marshmallows”}

set secondSnippet to the result

end tell

end tell

The second script checks for the existence of a URL-based group. If no such group is found, that URL is imported:

–– This script checks to make sure that a group based on a particular URL is present.

–– If not, it imports that group

set success to false

set groupURL to (“http://www.smilesoftware.com/te/example.textexpander” as text)

–– note coercion above: TE group source is type text, not URL

tell application “TextExpander”

set sourceList to the source of every group

if sourceList contains groupURL then

–– the desired group is already present

set success to true

else

set newGroup to import URL group using URL groupURL

–– the returned group is a placeholder for URL contents, which are downloaded asynchronously

repeat with i from 1 to 10

delay 1 –– allow some time for download, then poll the group placeholder

tell newGroup

–– find the number of snippets in the group

–– unless the group is supposed to be empty, zero snippets indicates download failure

count snippets

set snipCount to the result

if snipCount is not equal to 0 then

set success to true

exit repeat

end if

end tell

end repeat

end if

end tell

if not success then

beep –– real error handling goes here

end if

 

Again, we welcome your feedback on TextExpander’s new AppleScript capabilities.

Virtual Keyboards and TextExpander

Tuesday, March 29th, 2011

Virtual keyboards are on-screen representations of a keyboard which allow you to enter characters by clicking the mouse or other pointing device. That is, you move the mouse to the part of the screen where the ‘v’ key is, click the mouse, and a ‘v’ appears in your text document. (Note: there are other types of virtual keyboards in addition to the on-screen, mouse-driven variety, but this post does not cover them.) One reason to use a virtual keyboard is if you have trouble typing on a physical keyboard.

Mac Keyboard Viewer

Mac OS X built-in Keyboard Viewer

TextExpander has some issues with virtual keyboards. When you click the mouse, TextExpander assumes that you are moving the text insertion point within a document, selecting a range of text, changing to a different window or text area, or performing some kind of formatting or other command. Thus, when you click the mouse, TextExpander clears the buffer of typed characters it maintains to track when you type a snippet abbreviation.

For example, with the ‘ddate’ snippet, when you click the ‘d’ key on the virtual keyboard the first time, TextExpander clears the buffer because the mouse was clicked, then notices that a ‘d’ has been typed. When you click the ‘d’ key the second time, TextExpander again clears the buffer, then stores the ‘d’. The snippet never expands because TextExpander keeps clearing its buffer, never tracking more than one character at a time.

TextExpander version 3.1 fixed this problem by adding support for typing with the system’s built-in Keyboard Viewer and for Corallo Software’s VirtualKeyboard application. TextExpander 3.2.4 adds support for AssistiveWare’s KeyStrokes application.

If there is another virtual keyboard program that you are using, there is a “hidden” setting in TextExpander that will allow you to use it before support is “built-in” to TextExpander. Just contact support@smilesoftware.com for details.

Firefox Bug Affecting TextExpander Fixed!

Thursday, February 10th, 2011

A bug in Firefox and Chrome can deprive TextExpander of its ability to observe keyboard input by enabling “secure input”  and neglecting to disable it. We first posted about the issue last  June.

The Mozilla team have found a fix, and it’s available now in the Firefox nightly build. The fix is also slated to be available in Firefox 4.0b12.

You can read more about Secure Input and the bug.

You can also read the history of the Mozilla bug process for this particular bug.

Thank you to Josh Aas and the Mozilla team!

Smile and the new Mac App Store

Tuesday, January 11th, 2011

Mac App StoreThe Mac App Store is a big deal for third-party Mac developers like Smile. For the first time, Apple is making it easy to buy and install software without ever going to a website, downloading a demo, or clicking an installer. Because it’s built into the OS, every Mac user will have a convenient option for purchasing software.

PDFpen, PDFpenPro and DiscLabel were available on Day One. (We hope TextExpander will be available soon!) The Mac App Store is not our exclusive channel for sales. Customers are still able to download and purchase applications directly from smilesoftware.com. We have kept the same prices for both channels.

We will continue to provide updates to our existing customers outside the Mac App Store. Choose “Check for Update…” in the application menu to download the latest version. You can set automatic update checking and its frequency via the Update preference pane.

The versions of our software in the Mac App Store are functionally the same as the versions available on our site. We had to make a few adjustments to meet Apple’s criteria, and that resulted in a discrepancy in version numbers.

Updates for both Mac App Store-purchased software and independently-purchased software will be on the same schedule, although there may be a lag for the Mac App Store updates due to Apple’s review process.

You might have noticed that your Smile applications are not marked “Installed” in the Mac App Store. That’s because they weren’t purchased through the Mac App Store. The Mac App Store only supports updating products purchased via the Mac App Store. The fact that it shows some products purchased independently as installed is simply a convenience and is in some cases misleading.

If you have any questions at all, please let us know at support@smilesoftware.com. You’ll get a fast, friendly answer from our support team.

TextExpander 3.2.2 improves auto capitalization

Monday, December 13th, 2010

We’ve changed TextExpander’s automatic capitalization feature substantially in version 3.2.2 to improve its performance based on customer feedback. Previously, there were several situations where TextExpander would capitalize letters when it should not. The 3.2.2 version is much less likely to capitalize letters incorrectly. Download TextExpander 3.2.2.

A few specific factors frustrated TextExpander users:

1. TextExpander assumed you were starting a new sentence when switching from one application to another. That is, if you were typing an email, switched to your browser to look up something, then switched back to the email to finish your sentence, the first word typed would be capitalized regardless of its position within a sentence.

2. If you typed a period or other sentence-ending punctuation, then used the mouse to change the position of the insertion cursor, the next word typed would be capitalized regardless of its position within a sentence.

3. Any time you re-positioned the insertion cursor using the arrow keys, TextExpander would not auto-capitalize again until you typed a sentence-ending character.

These issues have been addressed in TextExpander 3.2.2. In applications that thoroughly support Apple’s accessibility interface, TextExpander can now examine the text near the insertion cursor to determine whether the cursor is in a sentence-starting location. Unfortunately, many popular applications do not support this interface, so users of applications such as BBEdit and Microsoft Word users will find that the new version of TextExpander just doesn’t automatically capitalize as often. At least unwanted capitalizations should no longer occur in those applications.

Another common case of unwanted capitalization resulted when typing web or email addresses. That is, typing Smile’s web address would result in: www.Smilesoftware.Com with unwanted capital ‘S’ and ‘C’. TextExpander now waits for a space or line break after punctuation before activating automatic capitalization.

Additionally, short snippets such as “i “ -> “I “ and “u “ -> “you “ used at the start of a sentence with capitalization enabled resulted in incorrect expansion output which has been fixed.

For the future, a few users have requested that “Eliminate double capitals at sentence start” be changed to “Eliminate double capitals at word start”. That is, it would suppress a second capital letter at the start of a word anywhere. This is helpful to avoid errors like “TRacy” or “NOrth”, but it does replace “OK” with “Ok” (which can be ‘fixed’ with an “OK” -> “OK” snippet). If you have an opinion on this possible future change, let us know your thoughts and reasoning.

Using Shell Scripts to Extend TextExpander

Wednesday, October 13th, 2010

In addition to plain text and formatted text, pictures snippets, TextExpander also supports AppleScript and shell scripts as content types. Your abbreviation will expand to whatever the script returns. This allows you to extend TextExpander in whatever ways you need. Here’s a recent example which started with a support question:

> I've created the following snippet with abbreviation: ,getdate:
>
> %date:EEEE% %date:d% %date:LLLL% %date:Y% - día %date:D% del año
>
> Which is converted to the following on my system:
>
> jueves 30 septiembre 2010 - día 273 del año
>
> However, I would like the day of the week and month to be in uppercase, as follows:
>
> Jueves 30 Septiembre 2010 - día 273 del año
>
> Do you know how to do this?

It seems that the Unicode date formatting doesn’t offer a way to specify that the month or day names should be returned in uppercase.

I was able to write a Perl script and to nest the ,getdate snippet to convert the first and third words to uppercase. I set my abbreviation to ,date and my Content: to Shell Script:

#!/usr/bin/perl
$_ = "%snippet:,getdate%";
m/(\S+) (\S+) (\S+)(.*)/;
$_ = ucfirst($1) . " $2 " . ucfirst($3) . "$4";
print "$_\n";

Here is what ,date returns right now with my system set to return date information in Spanish:

Miércoles 13 Octubre 2010 – día 286 del año

That which wasn’t possible before is possible now, thanks to the power of shell scripts in TextExpander.

Fixed A Troublesome TextExpander Bug

Tuesday, August 10th, 2010

Further to our post about disappearing snippets, we have identified at least one issue and have fixed it in TextExpander 3.1.1. We’ve seeded this fix to several customers and have received positive feedback that it fixed the problem for them.

Please download and install the TextExpander 3.1.1 update. If you do experience a snippet loss, please let us know. If there are any other issues, we want to find them.

Per our earlier post, please do the following if you experience the problem:

If you experience this problem, you can restore your snippet library by quitting TextExpander and restoring this file from your Time Machine or other backup:

[Home]/Library/Application Support/TextExpander/Settings.textexpander

Before you re-launch TextExpander, please also send a copy of the restored file to us at textexpander@smileonmymac.com. This is especially helpful if you find the problem recurs for you. If we gather enough settings files, hopefully we’ll find one with which we can reproduce the problem. If we can reproduce it we can almost certainly fix it. In the meantime, we’re very sorry for the inconvenience.

We appreciate your help in making TextExpander the best it can be.