📜 ⬆️ ⬇️

Applescript for general use in everyday office work

I would like to share my own work on several Applescript solutions, for which literally everyone can find an application, and at the same time hear examples of other similar universal “general purpose” solutions. I’ll make a reservation that I launch the scripts via hotkeys, linking the buttons to launching the necessary scripts via Quicksilver, this binding takes 5 seconds.

So, from such general-purpose scripts that fit literally everyone, regardless of activity, I created the following.
1. Send the selected file by mail with the desired subject of the letter, the desired text of the letter and the desired recipient:
property Myrecipient : "" property mysubject : "" property EmailBody : "" on run tell application "Finder" set sel to (get selection) end tell new_mail(sel) end run on open droppedFiles new_mail(droppedFiles) end open on new_mail(theFiles) tell application "Mail" set newMessage to make new outgoing message with properties {visible:true, subject:mysubject, content:EmailBody} tell newMessage make new to recipient with properties {address:Myrecipient} tell content repeat with oneFile in theFiles make new attachment with properties {file name:oneFile as alias} at after the last paragraph end repeat end tell end tell activate end tell end new_mail 


2. Open the desired folder:
 tell application "Finder" activate open folder "" of folder "" of folder "" of folder "Users" of startup disk end tell 

3. Make a reminder from the highlighted letter:
 tell application "Mail" using terms from application "Mail" set selectedMails to selection set theMessage to first item of selectedMails set theBody to "message:%3C" & message id of theMessage & "%3E" set theSubject to the subject of theMessage & " (From " & the sender of theMessage & ")" tell application "Reminders" set theList to list "Inbox" set newToDo to make new reminder with properties {name:theSubject, body:theBody, container:theList} end tell end using terms from end tell 

4. Paint the letter in, for example, red:
 tell application "Mail" set maillist to selection repeat with i from 1 to number of items in maillist set this_item to item i of maillist if class of this_item is message then set background color of this_item to red -- other colors are -- gray / green / orange / red end if end repeat end tell 

')
5. Get the path to a folder or file - let's say, for insertion into a letter or chat:
 >tell application "Finder" set sel to the selection as text set the clipboard to POSIX path of sel end tell 

Hot start keys seemed to me the most convenient way to do it through Alt - for “pan-system” calls, it is actually free, while on Cmd there are many basic functions inside applications, and on Ctrl - again, much is created by custom inside applications. And here alt + r - sent mail to reminders for example.

I would be very happy to see in the comments any script ideas that could be useful for routine operations, regardless of the type of activity.

Source: https://habr.com/ru/post/157003/


All Articles