Man­age win­dows on the Mac

Keep win­dows neat with OS X’s own built-in script­ing lan­guage Ap­pleScript

Mac Format - - IMPROVE - Alan Stone­bridge

Ap­pleScript will keep your Finder win­dows in place and un­der con­trol

SKILL LEVEL Can be tricky

IT WILL TAKE 20 min­utes

YOU’ll NEED Ap­pleScript Ed­i­tor

Win­dow man­age­ment in OS X hasn’t im­proved in a long time. Lion in­tro­duced the abil­ity to re­size win­dows from any edge or cor­ner, but this is still fid­dly at times – es­pe­cially when work­ing with a track­pad – and it doesn’t hold a can­dle to some­thing like the con­ve­nient short­cuts baked into re­cent ver­sions of Mi­crosoft Win­dows, which al­low you to quickly snap a win­dow to fill part of the desk­top.

There’s a good se­lec­tion of third-party util­i­ties for OS X that help you man­age win­dows, in­clud­ing Bet­terTouchTool/Bet­terS­napTool (, Moom ( and Divvy ( How­ever, if your needs are sim­pler – say, you reg­u­larly want to po­si­tion two win­dows in the left and right halves of your desk­top, re­spec­tively – all you re­ally need is Ap­pleScript, which is built into OS X.

OS X comes with two tools for au­tomat­ing tasks. You might al­ready have used Au­toma­tor, which is the eas­i­est to learn. The other is Ap­pleScript Ed­i­tor (lo­cated in /Ap­pli­ca­tions/Util­i­ties), which can talk to apps in greater de­tail us­ing Ap­pleScript, a script­ing lan­guage that can con­trol el­e­ments of OS X. Some apps pro­vide their own dic­tionary that de­fines words and phrases for things that you can query and con­trol with Ap­pleScript, but many more apps can be con­trolled us­ing a vo­cab­u­lary for com­mon ob­jects, such as win­dows, that OS X makes avail­able to all.

Open Ap­pleScript Ed­i­tor and choose File > Open Dic­tionary. First choose the App Store app from the list of those de­tected on your sys­tem. The win­dow that opens has three panes across the top. The left­most one lists only Stan­dard Suite, Text Suite and Type Def­i­ni­tions. Choose Open Dic­tionary again and choose Sa­fari. It un­der­stands an ad­di­tional set of phrases re­lated to its fea­tures, which are de­scribed to you when you choose ‘Sa­fari suite’.

OS X’s win­dow re­siz­ing is fid­dly with a track­pad, and it doesn’t hold a can­dle to Win­dows’ short­cuts

Ap­pleScript is de­signed to read a lot like a nat­u­ral lan­guage, the intention be­ing that it’s eas­ier to fol­low than script­ing lan­guages laden with punc­tu­a­tion and other es­o­teric syn­tax. Get­ting started can be daunt­ing, even though Ap­ple pro­vides a bunch of ex­am­ple scripts with OS X and a com­pre­hen­sive pro­gram­ming guide (see Jar­gon Buster). Study­ing sim­ple scripts that al­ready ex­ist is a good way to get a grasp of Ap­pleScript, and we’re go­ing to show how you can use it to deal with the univer­sal prob­lem of man­ag­ing win­dows on the desk­top.

We’re go­ing to write our scripts within Au­toma­tor, us­ing its Run Ap­pleScript ac­tion. Trig­ger­ing scripts from the key­board makes them an ef­fi­cient en­hance­ment to OS X. Ap­pleScript Ed­i­tor’s pref­er­ences in­clude an op­tion to add a Script menu to the menu bar to run your scripts, but we’ve ex­pe­ri­enced trou­ble get­ting key­board short­cuts as­signed to items in that menu to work. We’ll show you how to run Ap­pleScripts from OS X’s Ser­vices menu to over­come this is­sue. The sim­plest of our scripts let you re­size a win­dow to a spe­cific re­gion of the screen by press­ing your choice of mod­i­fier keys – ß,≈,å and ç – and a char­ac­ter key.

One thing our scripts won’t ad­dress well is multi-dis­play set­ups, which com­pli­cate the co­or­di­nate sys­tem de­pend­ing on how the dis­plays are laid out in > Sys­tem Pref­er­ences > Dis­plays > Ar­range­ment. Pro­fes­sion­ally de­vel­oped tools can deal with this, and are your best op­tion. How­ever, if your Mac’s pri­mary dis­play is ar­ranged lef­t­and top­most in the Dis­plays pane, or by tem­po­rar­ily dis­con­nect­ing ad­di­tional dis­plays, you’ll still be able to ben­e­fit from this tu­to­rial.

Ap­pleScript pro­vides a vo­cab­u­lary through which you can take con­trol of win­dows and other ab­strac­tions.

The Scripts menu en­ables you to quickly run scripts from the menu bar, or by us­ing a key­board short­cut.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.