10.5: Quick note creation in Mail via AppleScript
I'm always searching for something to write on when I want to take a quick note. I know that Mail in 10.5 includes a note function, but it's usually been too much trouble to launch Mail and then navigate the menus to select a new note. So I finally put together this little AppleScript that I use with Quicksilver's hotkeys to launch a new note with just one keystroke: tell application "Mail" activate end tell tell application "System Events" tell process "Mail" click the menu item "New Note" of the menu "File" of menu bar 1 end tell end tell I save the script as an application, and assign it to the F7 key in Quicksilver. Now when I need to take a quick note, it's just one key press away. As an alternative to using Quicksilver's hotkey, this script can be saved as an application and placed in the Dock, making a new note just one click away.
published on Wednesday, the 9. July 2008, macosxhints
10.5: Find current Space number via AppleScript
One drag about Apple's Spaces implementation in Leopard is that there is no way to access Spaces via AppleScript. While you can use AppleScript to select indvidual spaces by simulating keystrokes, it'd be nice to have some way to find what the current space is via AppleScript. Well, using PreFab Software's excellent UIBrowser, I was able to figure out how to accomplish that precise task with AppleScript. (I believe you'll need to check Enable Access for Asssistive Devices in the Universal Access pane of System Preferences, if you haven't already, for this to work. You'll also need the Spaces menubar extra to be visible, which you can enable in the Spaces pane of System Preferences.) The script will return the variable theCurrentSpace with the number of the currently displayed space. You can use that i...
published on Tuesday, the 4. March 2008, macosxhints
10.5: Switch Spaces using fn keys with Quicksilver
Adding to the multiple ways to switch spaces: here's a way to do it with just Blacktree's Quicksilver, without running any (other) third party apps. In the Spaces control panel, set control-number keys to switch directly to a space. Add a Quicksilver trigger, with this text (type dot and then this text): tell application "System Events" to keystroke (ASCII character 49) using control down Set the action as "Run as AppleScript" Set the trigger to use a keypress, then (you might have to hit the (i) icon to get the sidebar to pop out) set it to F1, and make sure you set it to activate on release. F1 should now jump to space 1. Do the same for F2, but with ASCII 50, and so on. You're just telling it to hit the control-n when you hit the function ...
published on Friday, the 22. February 2008, macosxhints
10.5: Use Caps Lock to send keystrokes via AppleScript
I finally had that eureka moment, on how to detect Caps Lock using Applescript, while trying to help out on this forum thread about auto-logging out from a Mac.The Applescript calls KeyboardViewerServer.app, and checks the value of the CAPS key via the Keyboard Viewer window. A return value of 1 means the Caps Lock key is down, and a return of 0 means it's up. The really strange -- but good -- thing is that even if the Keyboard Viewer window is not actually visible, the value still gets returned. (If it pops up the first time you run the script, just close its window). Here's a test script to demonstrate how it works:
published on Tuesday, the 12. February 2008, macosxhints
Updates come for KeyStrokes, SwitchXS, LayoutKitchen
AssistiveWare says it has released updates for three of its main programs. KeyStrokes, the company's predictive on-screen keyboard, is now in version 4; the main change is the addition of LayoutKitchen, which lets users create custom keyboards that can incorporate things such as voice commands, program launches and AppleScripts. The software also...
published on Monday, the 21. January 2008, macintosh-news-network
Send highlighted words/phrases to Google Desktop
I'm sure by now that you've had the chance to download Google Desktop (GD) and compare it to Spotlight. I am also sure that most people that have used GD can note many improvements, such as the ability to activate GD by highlighting a word or phrase in any application and then using a contextual menu or hotkey to bring up GD to perform a search and return the results.Well, since I am not yet able to put it into a contextual menu, I have chosen to use Butler to set up a smart item keystroke -- along with writing an AppleScript -- that will allow me to select a word or phrase from any application and then send it to GD for matching results. In order for the script to work, you must check 'Enable access for assistive devices' in the Universal Access System Preferences panel. I am sure it ca...
published on Tuesday, the 15. May 2007, macosxhints
Create smart playlists for all artists in iTunes
I wrote this short AppleScript to make a smart playlist for every artist in my iTunes folder. You'll need to enter your own directory on the line that starts set tunesFolder, possibly change the keystroke commands if you've changed yours in iTunes, and finally, edit the delay 1 lines if your machine is too slow to keep up.The script takes about one minute to process each 20 artists, so be patient. I was forced to use System Events, because there is no way to create smart playlists directly from AppleScript.[robg adds: I haven't tested this one, but you should probably also quit iTunes before running the script.]
published on Thursday, the 8. March 2007, macosxhints
10.4: Open URL in a new Safari window and minimize
I use Safari and browse with tabs. I like having everything in one window. Sometimes however, I come across a page that I am already viewing that I want to be in a separate window. So I made an Automator app to take care of it for me.Its a simple three step app. Start with the Get Current Webpage from Safari action in the Safari library, then add the Display Webpages (also in the Safari library) action (this will open your URL in a new window), and finally, add a Run AppleScript action with this script:on run {input, parameters} activate application "Safari" tell application "System Events" tell process "Safari" -- GUI Scripting statements: keystroke "m" using {command down} end tell end tell return inputend runSave this as an application somewhere on your hard drive. It takes about three seconds...
published on Friday, the 19. January 2007, macosxhints
Minimize all Finder windows at login via AppleScript
I like to leave a few Finder windows open, for easy access to projects I'm working on. However, I don't leave them all visible because they cover the desktop. Minimizing to the Dock is a great solution, except that they don't stay there after logging out. So each time the computer starts up, they're all over the desktop and I have to "option-click" the Minimize button on one of the windows to get them all into the dock.I wanted to automate this process on login, so after tinkering around with PreFab UI BrowserP, I came up with this little AppleScript:activate application "Finder"tell application "System Events" tell process "Finder" -- GUI Scripting statements: keystroke "`" using {command down} keystroke "m" using {command down, option down} end tellend tellEnter it in Scrpt Editor, and save it as an Application (Run Only), then add it to your login items. I found that sometimes afte...
published on Tuesday, the 2. January 2007, macosxhints
Print selected text from browser via AppleScript
I have been reading MacOSXHints for quite some time. In an effort to contribute and not just leech, here is a hint that I find useful daily. I miss the "Print Selection" option found in some browsers on Windows. I find this useful to quickly print directions, recipes, or anything else where I want an unformatted plain text print out. Combining some AppleScript and Terminal commands, I created an AppleScript addition that allows me to select text in my browser (currently Camino), click one button, and send it to my default printer. Two items need to be placed on your system to get this to work: Shell script to send the text string to the default printer. #! /bin/sh pbpaste | lpr I saved this as ~/Documents -> Scripts -> sel_lpr.sh An AppleScript to capture the highlighted text and send it to the clipboard: tell application "Camino" activate tell application "System Events" to keystroke "c" using command down...
published on Thursday, the 12. October 2006, macosxhints