如何用Apple Script结合Automator工作流实现截图+时间发送至iMessage好友?
Automator + Apple Script: Send Screenshot with Timestamp via iMessage
Hey there! I've got a straightforward solution to tie your existing screenshot Automator workflow to sending that screenshot (plus a timestamp) to a specific iMessage buddy using AppleScript. Here's how to set it up:
Step 1: Update Your Automator Workflow
- Open your existing "Take ScreenShot" Automator workflow.
- Scroll to the bottom of your workflow, then search for the Run AppleScript action in the left-side actions library. Drag it into your workflow as the final step.
Step 2: Paste the Custom AppleScript
Replace the default placeholder script in the Run AppleScript action with this code snippet:
-- Generate a human-readable timestamp (adjust format as needed) set currentTimestamp to do shell script "date '+%Y-%m-%d %H:%M:%S'" set messageContent to "Screenshot captured at: " & currentTimestamp -- Replace this with your recipient's phone number or Apple ID set targetRecipient to "555-123-4567" -- Pull the screenshot data from your clipboard set screenshotImage to the clipboard as TIFF picture -- Send everything via iMessage tell application "Messages" set iMessageService to first service whose service type is iMessage set targetBuddy to buddy targetRecipient of iMessageService -- Send timestamp message first, then the screenshot send messageContent to targetBuddy send screenshotImage to targetBuddy end tell
Important Adjustments to Make
- Recipient Details: Swap
555-123-4567with your friend's actual phone number (include country code if they're overseas) or their Apple ID email address. - Timestamp Format: If you prefer a different date/time style, tweak the
date '+%Y-%m-%d %H:%M:%S'part. For example:'+%m/%d/%Y %I:%M %p'gives you09/15/2024 02:45 PM'+%A, %B %d, %Y at %H:%M'gives youSunday, September 15, 2024 at 14:45
- Permissions: The first time you run this workflow, macOS will prompt you to grant access to Messages and the clipboard. Make sure to allow these permissions—otherwise the script can't send the message or access your screenshot.
How It All Comes Together
- Your existing Automator step captures the screen and copies the screenshot to your clipboard.
- The AppleScript grabs the current time, formats it into a clear message, then pulls the screenshot from the clipboard.
- It opens the Messages app, locates your specified buddy, sends the timestamp message, and follows up with the screenshot attachment.
内容的提问来源于stack exchange,提问作者Tim Apple
相关产品推荐
相关产品推荐

