Convert Numbers sheets into Keynote slides via AppleScript
I wrote an AppleScript to copy all the tables and data from a Numbers document into a Keynote document. Each sheet becomes on slide on Keynote. Here's the code: tell application "Keynote" activate make new slideshow -- create a slide show set newSlideShow to slideshow 1 -- keep a reference end tell tell application "Numbers" activate tell document 1 set nombreFeuilles to the count of sheets end tell end tell --display dialog nombreFeuilles repeat with i from 1 to nombreFeuilles tell application "Numbers" activate tell table 1 of sheet i of document 1 to activate tell application "System Events" to keystroke "a" using {command down} tell application "System Events" to keystroke "c" us...
published on Friday, the 12. February 2010, macosxhints
Minimize windows in slow motion via hot screen corner
Do you like the slow motion effect on minimization, but do not like to hold the Shift key every time you do it -- and you dislike double-clicking the title bar when you want to minimize a window? If so, then take a look at the following AppleScript. I use this AppleScript with CornerClick, which is a (free) utility that lets you assign actions, including running AppleScripts, to the corners of your screen. With the following Applescript, you can trigger a "Minimize with slow motion effect." Assign it to a corner using CornerClick, and you can minimize a window in slow motion with a flick of the mouse. Here's the script: tell application "System Events" keystroke "m" using command down key down shift delay 0.3 key up shift end tell tell appl...
published on Friday, the 4. December 2009, macosxhints
10.6: Jump to path via global Service
When I'm working anywhere in 10.6 other than in the Finder, I might suddenly need to go to some path. It kind of bothers me that I have to Command-Tab to the Finder, and then do the Shift-Command-G keystroke. Also, I might want to open some Macintosh-style path (:) instead of POSIX-style (/) path. Now, in 10.6, I can jump to a path using a Service. Here is a basic intro: Open Automator and choose Service from the Templates chooser. Make sure the Service receives "no input" in the pop-up menu at the top. Drag the Run AppleScript Action (in the Utilities Library), into the work area on the right, and enter this AppleScript in the Run AppleScript box: --Go to...
published on Tuesday, the 3. November 2009, macosxhints
Launch items in Stacks via AppleScript and keyboard
Unfortunately, my two favorite application launchers -- Butler and Quicksilver -- aren't quite up to snuff with Snow Leopard just yet. Spotlight works OK most of the time, but I've started to rely on the Dock's stacks for launching what I need. However, I'm very keyboard-centric, and I don't like going to my mouse any more than I have to, so I wrote an AppleScript that will open the Stack for me, and using 10.6's new Services features, I can trigger that AppleScript with a keyboard shortcut. Here is the script: tell application "System Events" key code 99 using control down -- ctl-F3 to focus on Dock keystroke "Applications" -- should take focus to Applications folder key code 36 -- hit Return to open stack end tell Once the Stack opens, you can type in the first few letters of an application and hit return to launch it. The script itself is fully compatible with 10.5 as well, but assigning it to a keyboard shortcut natively is not. The following bit ...
published on Wednesday, the 14. October 2009, macosxhints
AppleScript to fix a Plantronics headset issue in Skype
I use Skype on my MacBook all day for work, and have always wanted to use a Bluetooth headset with it, but always ran into bad quality. I finally found a headset that worked well, the Plantronics Voyager Pro. However, there was still an issue in that it wouldn't disconnect after hanging up the call, causing the battery on both the MacBook and the earpiece to drain way too quickly. To remedy this, I wrote this AppleScript, which I run with a keystroke (via FastScripts) to hang up a Skype call and disconnect the bluetooth headset. Here's the script: tell application "Skype" to activate menu_click({"Skype", "Call", "Hang Up"}) tell application "System Events...
published on Friday, the 19. June 2009, macosxhints
Create a new Sticky widget from entered text
The following AppleScript asks you for some text, copies it to the clipboard, then creates a new Sticky widget and pastes the text you entered. Here's the code: set the clipboard to text returned of (display dialog "Enter some text for your new Sticky widget..." default answer "Note: ") set stickywidget to ((path to startup disk) as Unicode text) & "Library:Widgets:Stickies.wdgt" tell application "Finder" to open stickywidget delay 1 tell application "System Events" keystroke tab delay 0.2 keystroke tab delay 1 keystroke "v" using {command down} end tell The two delay lines may need adjustment for different systems; experiment to find what works for you. Once you ha...
published on Friday, the 29. May 2009, macosxhints
Open Finder Inspector panel at login
I really love Finder's Inspector window, specially on a large screen like an iMac's, but I'd prefer to have it open when my Mac starts. (Yes, it is just three keystrokes, but I prefer to have it already on automatically.) So, as Finder doesn't have this option, I've created an AppleScript to do it:try tell application "Finder" activate end tell tell application "System Events" tell process "Finder" tell menu bar 1 tell menu bar item "File" tell menu "File" click menu item "Show Inspector" end tell end tell end tell end tell end tellend tryPaste the above into Script Editor, save it as an application, and then I add it to your login items. You must have enabled Access for Assistive Devices, which can be found in the Universal Access System Preferences panel.
published on Wednesday, the 10. December 2008, macosxhints
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