Skip to content

Instantly share code, notes, and snippets.

@ChristoferK
ChristoferK / Click Menu Item.applescript
Last active September 11, 2018 05:03
[Click Menu Item] A code refactoring of the original pair of handlers, now unified into a single handler that receives an application and a list of strings that represent a path through the application's menu tree to the menu item that is to be clicked. #AppleScript #recursion #menus #menu_items #System_Events
to clickMenuItem(pObj, mItems as list)
local pObj, mItems
if mItems = {} then return
script menuItem
use application "System Events"
property m0 : item 1 of mItems
property mN : rest of mItems
@ChristoferK
ChristoferK / Minimise Background Safari Windows.js
Last active August 7, 2018 22:46
[Minimise Background Safari Windows] Minimises all Safari windows except the one in focus. #JXA #JavaScript #Safari
windows = Application('Safari').windows()
windows.shift() // Remove front window from array
windows.map(w=>w.miniaturized = true)