10个实用案例:用python-shortcuts自动化你的iOS日常任务
2026/8/10 22:29:37 网站建设 项目流程

10个实用案例:用python-shortcuts自动化你的iOS日常任务

【免费下载链接】python-shortcutsCreate Siri Shortcuts with Python项目地址: https://gitcode.com/gh_mirrors/py/python-shortcuts

python-shortcuts是一个强大的工具,让你能够用Python轻松创建Siri Shortcuts,通过简单的代码实现iOS设备上的各种自动化任务。无论是处理文件、管理照片还是与网络服务交互,它都能帮你节省时间,让日常操作更加高效。

1. 快速获取最新照片并自动分享 📸

利用GetLastPhotoAction可以轻松获取相册中最新拍摄的照片,结合分享功能实现自动发送。这个功能特别适合需要快速分享生活瞬间的场景。

from shortcuts import Shortcut from shortcuts.actions.photo import GetLastPhotoAction shortcut = Shortcut() shortcut.actions.append(GetLastPhotoAction()) # 这里可以添加分享动作 shortcut.dump('get_last_photo.shortcut')

相关源码:shortcuts/actions/photo.py

2. 一键保存网页内容到文件 📄

使用GetURLActionSaveFileAction组合,可以将网页内容自动下载并保存到指定位置,方便稍后阅读或存档重要信息。

from shortcuts import Shortcut from shortcuts.actions.web import GetURLAction from shortcuts.actions.files import SaveFileAction shortcut = Shortcut() shortcut.actions.append(GetURLAction(url='https://example.com/article')) shortcut.actions.append(SaveFileAction(path='/Documents/Articles/')) shortcut.dump('save_web_content.shortcut')

相关源码:shortcuts/actions/web.py、shortcuts/actions/files.py

3. 自动创建日期命名的文件夹 📁

CreateFolderAction配合日期变量,可以自动生成带有日期的文件夹,帮助你更好地组织文件和照片。

from shortcuts import Shortcut from shortcuts.actions.files import CreateFolderAction from shortcuts.actions.date import GetCurrentDateAction shortcut = Shortcut() shortcut.actions.append(GetCurrentDateAction(format='yyyy-MM-dd')) shortcut.actions.append(CreateFolderAction(path='/Documents/Photos/{CurrentDate}/')) shortcut.dump('create_date_folder.shortcut')

4. 批量处理图片格式转换 🔄

ImageConvertAction支持将图片转换为不同格式并调整压缩质量,适合需要统一图片格式的场景。

from shortcuts import Shortcut from shortcuts.actions.photo import SelectPhotoAction, ImageConvertAction shortcut = Shortcut() shortcut.actions.append(SelectPhotoAction()) shortcut.actions.append(ImageConvertAction(format='JPEG', compression_quality=80)) shortcut.dump('convert_images.shortcut')

相关源码:shortcuts/actions/photo.py

5. 自动展开短链接 🔗

ExpandURLAction可以将缩短的URL自动展开为原始链接,避免访问未知链接的安全风险。

from shortcuts import Shortcut from shortcuts.actions.web import ExpandURLAction shortcut = Shortcut() shortcut.actions.append(ExpandURLAction()) shortcut.dump('expand_url.shortcut')

相关源码:shortcuts/actions/web.py

6. 读取文件内容并进行文本处理 📝

结合ReadFileAction和文本处理动作,可以自动读取文件内容并进行格式转换、提取关键信息等操作。

from shortcuts import Shortcut from shortcuts.actions.files import ReadFileAction from shortcuts.actions.text import TextAction shortcut = Shortcut() shortcut.actions.append(ReadFileAction(path='/Documents/notes.txt')) shortcut.actions.append(TextAction(action='uppercase')) shortcut.dump('process_text.shortcut')

7. 定时打开指定网页 ⏰

使用时间触发和OpenURLAction,可以在特定时间自动打开网页,帮助你准时查看日程或新闻。

from shortcuts import Shortcut from shortcuts.actions.web import OpenURLAction shortcut = Shortcut() shortcut.actions.append(OpenURLAction(url='https://calendar.example.com')) # 设置定时触发 shortcut.dump('schedule_open_url.shortcut')

相关源码:shortcuts/actions/web.py

8. 自动追加内容到日志文件 📋

AppendFileAction可以将文本内容追加到指定文件,适合创建简单的日志记录系统。

from shortcuts import Shortcut from shortcuts.actions.files import AppendFileAction from shortcuts.actions.date import GetCurrentDateAction shortcut = Shortcut() shortcut.actions.append(GetCurrentDateAction()) shortcut.actions.append(AppendFileAction(path='/Documents/log.txt')) shortcut.dump('append_log.shortcut')

相关源码:shortcuts/actions/files.py

9. 拍照并自动保存到指定文件夹 📸→📁

结合CameraActionSaveFileAction,可以实现在拍照后自动将照片保存到指定位置,方便照片管理。

from shortcuts import Shortcut from shortcuts.actions.photo import CameraAction from shortcuts.actions.files import SaveFileAction shortcut = Shortcut() shortcut.actions.append(CameraAction()) shortcut.actions.append(SaveFileAction(path='/Documents/InstantPhotos/')) shortcut.dump('camera_save.shortcut')

相关源码:shortcuts/actions/photo.py、shortcuts/actions/files.py

10. URL编码/解码工具 🔡

URLEncodeActionURLDecodeAction可以帮助处理URL编码问题,在进行网络请求时非常实用。

from shortcuts import Shortcut from shortcuts.actions.web import URLEncodeAction, URLDecodeAction shortcut = Shortcut() # 编码示例 shortcut.actions.append(URLEncodeAction()) # 或解码示例 # shortcut.actions.append(URLDecodeAction()) shortcut.dump('url_encode_decode.shortcut')

相关源码:shortcuts/actions/web.py

如何开始使用python-shortcuts

要开始使用这些自动化功能,首先需要安装python-shortcuts:

git clone https://gitcode.com/gh_mirrors/py/python-shortcuts cd python-shortcuts pip install -r requirements.txt

创建好的.shortcut文件可以通过iCloud或AirDrop传输到iOS设备,然后在快捷指令应用中打开使用。更多详细教程和动作说明,请参考项目文档:docs/tutorial.md

通过这些实用案例,你可以看到python-shortcuts如何帮助你简化iOS日常任务。无论是个人使用还是工作场景,它都能为你节省大量时间,让自动化变得简单而强大!

【免费下载链接】python-shortcutsCreate Siri Shortcuts with Python项目地址: https://gitcode.com/gh_mirrors/py/python-shortcuts

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询