There are thousands of ways that you can use shortcuts on iPhone and iPad to make your life easier. You can build actions to control your home, play music, place calls, send messages, get a rundown of your schedule, and more.
One of the most powerful sections at your disposal in the Shortcuts app is called Scripting. This menu lets you work with device functions like setting light or dark appearance, adjusting screen brightness or setting Do Not Disturb.
But it's also a lot more than that. There are actions for creating shortcuts that work one way in certain conditions, or another way in different conditions. You can create dictionaries that you can then use for list-based shortcuts. Encode things in Base64, have a shortcut count a particular kind of item passed into an action, and so much more.
For me, it's Scripting that really unlocks the versatility of Shortcuts as a tool for productivity and everyday life. This first look won't really dive into scripting specifics but will get you acquainted with the Scripting action menu and what the actions in different sections do. I'll also provide examples of shortcuts built using scripting actions.
What is the Scripting section in the Shortcuts app?
The Scripting actions menu in Shortcuts is, in a lot of ways, a "system actions" menu. It encompasses so many things that iOS and iPadOS can do as part of the system, like open an app or setting Do Not Disturb.
But it's also more of an "advanced actions" menu for Shortcuts as a whole. It's where some of the most interesting shortcut building can take place. You can use the actions in the Scripting menu to modify how your shortcuts work or to power complex shortcuts with multiple choices and menus, creating, essentially, small apps within the Shortcuts app.
The Scripting menu is split into multiple sections with a variety of potential actions:
- Apps: This has only one action right now: Open App. This action opens any app you'd designate.
- Control Flow: These actions, like Choose from Menu, If, Repeat, and Wait, as the section title would suggest, control how a shortcut flows and can change how it operates in some cases. A shortcut with the If action, for instance, can run one way if a specific condition is met, or another way if it isn't.
- Device: These are your actions that control different functions on your iPhone or iPad. Get your battery level or other device information, turn Bluetooth on or off, etc., these actions also control or give you information on some aspect of your device. A personal favorite of mine is Set Playback Destination, which I use to avoid having to fiddle around with AirPlay menus.
- Dictionaries: A dictionary is a type of database that stores key values, essentially sets of terms (keys) and definitions (key values). A dictionary used in a shortcut will be presented to you as a list. Tapping an item on that list will open its associated key-value under the remaining parameters of the shortcut. For more information on working with dictionaries and how you might use them, check out my guide here.
- Files: There are two actions in this list: Base64 Encode, which either encodes or decodes text using Base64 encoding, and Generate Hash, which generates an MD5/SHA1 has from a given input.
- Items: These actions all accept some kind of input and do something with it. You can, for instance, count a number of words or other items passed into the Count action, or the name of everything passed into the Get Name input.
- Lists: These actions all work with lists of items passed into them. The Choose from List action, for instance, is often if not always essential when you're working with a dictionary from which you'd like to choose an item. You can also specify a list that needs to be passed into an upcoming action.
- Math: This one's pretty straightforward; you use these actions when your shortcut needs to do math. There are actions for performing calculations, calculating statistics of provided numbers, or rounding provided numbers.
- Measurements: These two actions deal with measurements. You can convert measurements into new units or move a measurement into the next action.
- Network: These actions deal with certain network functions. This is where you'll find actions for turning cellular data and Wi-Fi on or off, or setting Airplane Mode. you can also get your current IP address or other details about your current network.
- No-ops: These two actions, very specifically do nothing within the context of the shortcut they're in. Comment is just a block where you can explain how a shortcut or part of a shortcut works. The Nothing action "does nothing and produces no output," and you can use to to prevent any input from passing into the next action.
- Notification: Using these actions, you can offer different prompts to the user. You can ask for input, play a sound, vibrate the device, show a notification, and show an alert based on what you're actions are doing.
- Numbers: You can use these actions to work with numbers in a variety of different ways. There are actions for formatting something's file size into text, formatting information on a number, getting numbers from an input, passing a number into an input, or generating a random number.
- Shell: Only one action here, which lets you run a shell script over SSH.
- Shortcuts: These actions are for the Shortcuts app itself, and these are how you get a list of your current shortcuts, or how you run a shortcut inside of another shortcut.
- Variables: These actions let you work with variables inside your shortcuts. You can either append an action's input to a particular variable or simply create a new variable.
- X-Callback: These actions use Apple's older x-callback URL scheme for opening and sending information between apps. You can perform a specific x-callback action, or encode/decode text passed into the URL Encode action to be suitable for inclusion into a URL.
I know, that seems like a lot. There's a reason that I tell most people looking to use Shortcuts to stick to the Gallery tab. But if you're just getting started with Shortcuts, and are interested in the Scripting section, now you know what to expect from each of the available categories.
Practical scripting applications
My favorite scripting action might just be the If action. I love a good toggle switch, and that's exactly what If lets me make. I also love executing shortcuts with my voice, because it's cool. Custom toggle switches that I can activate with my voice? That's my kind of shortcut.
I created the Lights shortcut (so named so that I could say "Hey Siri, Lights") as one such toggle switch. When activated, the Home action gets the power state of my Nanoleaf Aurora, the last light that I have on in my room before I go to bed, then passes it to the If action. If the Aurora is off, then it turns the Aurora on. If the Aurora is already on, then the shortcut turns the Aurora off. Here's what it looks like:
As you can see, it's as simple as placing the action you want the shortcut to take right under either the If or Otherwise entry, which the If action places there automatically when constructing the shortcut.
I find this to be a much better solution than pawing through the Control Center to the Home widget or saying "Hey Siri, turn on Aurora," or "Hey Siri, turn off Aurora." Now, I just have to say "Hey Siri, Lights," and the state of my Aurora panels changes depending on its current state. It's efficient and I love it.
Another scripting shortcut that I've made that I absolutely love is Send Audio. I have a number of different AirPlay-capable speakers in my home that I use in different rooms, like my Libratone Zipp or my HomePods in a stereo pair. This shortcut uses the Choose Menu action with four different menu items, three for the speakers, and one for setting the audio destination back to the device itself. It looks like this:
You'll note that, like the If action, you place the action you want each menu item to initiate under the label below the Choose From Menu action itself.
Next time, I'm going to be explorimg the 'If' action more in depth, showing just what it does and how you can use it to build useful shortcuts for your everyday life.