Example - Passing a Value to a Shortcut Using Python

Share your macOS, iOS, and iPadOS shortcuts here. Post your shortcut in a new topic and be sure to describe thoroughly (screenshots, full text of any scripts, apps used, etc).
User avatar
DaveL17
Posts: 7291
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Example - Passing a Value to a Shortcut Using Python

Post by DaveL17 »

Passing data to a Shortcut using Python is easy using an embedded script.

Code: Select all

import os

val = indigo.variables[123456].value
os.system(f'/usr/bin/shortcuts run "Post Event to Calendar" <<< \"{val}\"')
Note the escaped double-quotes for the shortcut payload. These are important to ensure that payloads with embedded spaces are sent as an encapsulated string object.

Apple Shortcut
Get Text From - Shortcut Input
Calendar - Add New Event
Screenshot 2023-03-13 at 6.56.59 PM.png
Screenshot 2023-03-13 at 6.56.59 PM.png (304.8 KiB) Viewed 1083 times
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts

Return to “Apple Shortcuts”