Scripting Actions

Table of contents

  1. Apps
    1. App ID Shorthands
    2. Hide App
    3. Hide Apps
    4. Kill All Apps
    5. Kill App
    6. Open App
    7. Quit All Apps
    8. Qut App
    9. Split Apps
  2. Dictionaries
    1. Get Dictionary
    2. Get Keys from Dictionary
    3. Get Value from Dictionary
    4. Get Values from Dictionary
    5. Set Value in Dictionary
  3. Items
    1. Get Name
    2. Set Name
  4. Lists
    1. Choose from List
    2. Get First Item
    3. Get Last Item
    4. Get List Item
    5. Get List Items
    6. Get Random Item
    7. List
  5. Measurement
    1. Convert Measurement
    2. Create Measurement
  6. Numbers
    1. Format Number
    2. Get Numbers
    3. Random Number
  7. Passwords
    1. Search Passwords
  8. System
    1. Dismiss Siri

To use actions in this category, use this include statement:

#include 'actions/scripting'

Apps

App ID Shorthands

Shorthands are built into any of the following actions accepting App IDs. However, if you use these values they must be available at compile time.

  • appstore
  • files
  • shortcuts
  • safari
  • facetime
  • notes
  • phone
  • reminders
  • mail
  • music
  • calendar
  • maps
  • contacts
  • health
  • photos

Hide App

Hide an app.

hideApp(text appID)

Hide Apps

Hide multiple apps. Allows exception.

hideAllApps(text ...?except)

Kill All Apps

This will quit all the apps running on the device without asking to save changes!

Kills all apps. Allows exceptions.

killAllApps(text ...?except)

Kill App

This will not ask to save changes!

Kill an app.

killApp(text appID)

Open App

Open an app.

openApp(text appID)

Contributed by JosephShenton.


Quit All Apps

Quits all apps. Allows exceptions.

quitAllApps(text ...?except)

Qut App

Quit an app.

quitApp(text appID)

Split Apps

Split apps across the screen.

enum appSplitRatio {
    'half',
    'thirdByTwo',
}

splitApps(text firstAppID, text secondAppID, appSplitRatio ?ratio = "half")

Dictionaries

Get Dictionary

Get the dictionary from input.

getDictionary(variable input): dictionary

Get Keys from Dictionary

Get only the keys from the dictionary.

getKeys(dictionary dictionary): array

Get Value from Dictionary

For constants only, otherwise dictionary['key'] syntax should be used.

getValue(dictionary dictionary, text key)

Get Values from Dictionary

Get only the values from the dictionary.

getValues(dictionary dictionary): array

Set Value in Dictionary

Set the value of key to value in dictionary.

setValue(variable dictionary, text key, text value)

Items

Get Name

Get the name of an item.

getName(variable item)

Set Name

Set the name of an item.

setName(variable item, text name, bool ?includeFileExtension = false)

Lists

Choose from List

Prompts the user to choose from a list.

chooseFromList(variable list, text ?prompt, bool ?selectMultiple = false, bool ?selectAll = false)

Get First Item

Get first item in a list.

getFirstItem(variable list)

Get Last Item

Get the last item in a list.

getLastItem(variable list)

Get List Item

Get item from list at index. Keep in mind Shortcuts starts counting indexes at 1.

getListItem(variable list, number index)

Get List Items

Get items from a list between two indexes. Keep in mind Shortcuts starts counting indexes at 1.

getListItems(variable list, number start, number end): array

Get Random Item

Get random item from list.

getRandomItem(variable list)

List

Create a list.

list(text ...listItem)

Measurement

Convert Measurement

enum measurementUnitType {
    'Acceleration',
    'Angle',
    'Area',
    'Concentration Mass',
    'Dispersion',
    'Duration',
    'Electric Charge',
    'Electric Current',
    'Electric Potential Difference',
    'V Electric Resistance',
    'Energy',
    'Frequency',
    'Fuel Efficiency',
    'Illuminance',
    'Information Storage',
    'Length',
    'Mass',
    'Power',
    'Pressure',
    'Speed',
    'Temperature',
    'Volume',
}

convertMeasurement(variable measurement, measurementUnitType unitType, text unit)

Create Measurement

enum measurementUnitType {
    'Acceleration',
    'Angle',
    'Area',
    'Concentration Mass',
    'Dispersion',
    'Duration',
    'Electric Charge',
    'Electric Current',
    'Electric Potential Difference',
    'V Electric Resistance',
    'Energy',
    'Frequency',
    'Fuel Efficiency',
    'Illuminance',
    'Information Storage',
    'Length',
    'Mass',
    'Power',
    'Pressure',
    'Speed',
    'Temperature',
    'Volume',
}

measurement(text magnitude, measurementUnitType unitType, text unit)

Numbers

Format Number

Format number based on decimal place.

formatNumber(number number, number ?decimalPlaces = 2): number

Get Numbers

Get numbers from input.

getNumbers(variable input): number

Random Number

Returns a random number between min and max.

randomNumber(number min, number max): number

Passwords

Search Passwords

Searches passwords in the Passwords app.

searchPasswords(text query)

System

Dismiss Siri

Dismisses Siri.

dismissSiri()

Copyright ©. Distributed under the GPL-2.0 License. Siri Shortcuts and Mac are registered trademarks of Apple Inc. Apple is not involved in this project in any way. Do not contact Apple Support unless you are having an issue with the Shortcuts app itself.