10个实用案例:用python-shortcuts自动化你的iOS日常任务
10个实用案例用python-shortcuts自动化你的iOS日常任务【免费下载链接】python-shortcutsCreate Siri Shortcuts with Python项目地址: https://gitcode.com/gh_mirrors/py/python-shortcutspython-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.py2. 一键保存网页内容到文件 使用GetURLAction和SaveFileAction组合可以将网页内容自动下载并保存到指定位置方便稍后阅读或存档重要信息。from shortcuts import Shortcut from shortcuts.actions.web import GetURLAction from shortcuts.actions.files import SaveFileAction shortcut Shortcut() shortcut.actions.append(GetURLAction(urlhttps://example.com/article)) shortcut.actions.append(SaveFileAction(path/Documents/Articles/)) shortcut.dump(save_web_content.shortcut)相关源码shortcuts/actions/web.py、shortcuts/actions/files.py3. 自动创建日期命名的文件夹 CreateFolderAction配合日期变量可以自动生成带有日期的文件夹帮助你更好地组织文件和照片。from shortcuts import Shortcut from shortcuts.actions.files import CreateFolderAction from shortcuts.actions.date import GetCurrentDateAction shortcut Shortcut() shortcut.actions.append(GetCurrentDateAction(formatyyyy-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(formatJPEG, compression_quality80)) shortcut.dump(convert_images.shortcut)相关源码shortcuts/actions/photo.py5. 自动展开短链接 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.py6. 读取文件内容并进行文本处理 结合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(actionuppercase)) shortcut.dump(process_text.shortcut)7. 定时打开指定网页 ⏰使用时间触发和OpenURLAction可以在特定时间自动打开网页帮助你准时查看日程或新闻。from shortcuts import Shortcut from shortcuts.actions.web import OpenURLAction shortcut Shortcut() shortcut.actions.append(OpenURLAction(urlhttps://calendar.example.com)) # 设置定时触发 shortcut.dump(schedule_open_url.shortcut)相关源码shortcuts/actions/web.py8. 自动追加内容到日志文件 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.py9. 拍照并自动保存到指定文件夹 →结合CameraAction和SaveFileAction可以实现在拍照后自动将照片保存到指定位置方便照片管理。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.py10. URL编码/解码工具 URLEncodeAction和URLDecodeAction可以帮助处理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-shortcutsgit 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),仅供参考