How to support this blog?

To support this blog, you can hire me as an OmegaT consultant/trainer, or you can send translation and project management jobs my way.

Search the site:

Showing posts with label Mail. Show all posts
Showing posts with label Mail. Show all posts

Everything you wanted to know about modifying application shortcuts, and more...

Modifying application shortcuts

Or, how to spend two hours on your machine on a Sunday morning, when you could go take a walk instead...

Here I talk about an itch I felt the need to scratch this morning, and about 2 applications: CheatSheet, and customShortcuts, and I put a lot of references at the end, so have fun reading!


You can change shortcuts in System Preferences > Keyboard > Shortcuts > App Shortcuts

Most of the things you'll ever need to do can be done there.

But then, some can't.

This morning, I realized that in Mail.app, moving from Delete (Cmd+Del) to Mark as Read (Shift+Cmd+U) when I read and sort my mail, was not what I wanted.

When I read my mail, there are obvious deletes, but a lot of my casual mail can just be not read (discussion lists, where only a few threads are interesting), or specifically marked for later reference. But moving from Cmd+Del to Shift+Cmd+U involves a lot of friction and I want to get rid of that.

I want to have something like:

  • Cmd+Del = Mark as Read (or Mark as Unread, depending on context)
  • Shift+Cmd+Del = Delete
    and since that one is taken by "Erase Deleted Items > In All Accounts...", which I never use, I'd move that item to
  • Alt+Shift+Cmd+Del = Erase Deleted Items > In All Accounts...

That way, I have my morning "mail discussion parsing" workflow all centered on Del, which is a Good Thing™.

The problem is that the System Preference panel has its ideas on what can and cannot be done, and won't allow us to assign Cmd+Del to anything but Delete...

I know there are solutions that give you access to key bindings data, things that are really interesting and let you dive into the intricacies of the OS, but I was not really in that mood this morning (I put all the references at the bottom, there is plenty to read and play with, when you have time).

I remembered that there was an app that gives you all the shortcuts available in any given app (at least apps that live into the macOS GUI system, i.e. basically anything that has a real macOS menu at the top of the window, including Java apps like OmegaT, Electron apps like TMXEditor, etc.), the app is "CheatSheet" and can be found here:

https://www.mediaatelier.com/CheatSheet/

Just out of renewed curiosity, I decided to take a peek, just in case...

And there, behold! There is a link to that companion app: "CustomShortcuts" that (also) "works hand in hand with CheatSheet" by allowing you to edit shortcuts directly in the CheatSheet interface, which is pretty neat...

https://www.houdah.com/customShortcuts/

After a quick download and a few authorizations, I can now do what I wanted to do (assign Cmd+Del to Mark as Read, etc.), plus customShortcuts has autocompletion of menu item names, so you don't have to actually check the target application interface and worry about whether "..." is three dots, or an ellipsis… (← this thing).

Et voilà, I've got my workflow fixed now, I can spend the rest of my Sunday with my heart at ease, and here are the references I promised:


References

Post scriptum

You may want to give CheatSheet a "longish" delay before appearing when you hit Cmd, because it gets tiring real quick to have it pop up while you think about the shortcut you actually want to hit while holding Cmd, which really happens all the time...

In 2009, I had put together a similar thing on how to play with keybindings in the shell. It is here:
Bash (command line) shortcuts

Random mail...

Sometimes a wifi service wants your mail to register on their service. Sometimes it's to grant you full access, sometimes it is just to give you a few minutes so that you get their confirmation mail and register.

In any case, you generally don't want to give your email to just about anybody. I was thinking of creating a random mail generator that creates  valid "enough" mails that they pass muster when you paste them in a mail field. Because sometimes, the few minutes you are granted to confirm that email are enough to just check your own mail and be done with the wifi access.


So, here it is.

------✂︎------✂︎------✂︎------✂︎------✂︎------

use scripting additions

global mailCharacters
set mailCharacters to ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

set myName to myRandomString(10)
set myDomain to myRandomString(10)
set myExtension to myRandomString(3)

set myNewMail to myName & "@" & myDomain & "." & myExtension
set the clipboard to myNewMail

on myRandomString(n)
set myString to ""
set myLength to random number from 2 to n
repeat with i from 1 to myLength
set myString to myString & item (random number from 1 to length of mailCharacters) of mailCharacters
end repeat
end myRandomString

------✂︎------✂︎------✂︎------✂︎------✂︎------


The script creates something like:

[between 1 and 10 characters]@[between 1 and 10 characters].[between 1 and 3 characters]

and puts it into the clipboard so that you just have to run the script, and paste in the field where you need to put a mail.

It's pretty trivial, but it is just what I need.

Also, if you're a tad conscious about security, you should use a VPN over a free wifi, but that's another story.

Applescript everywhere

Artificial languages are no different from natural languages. Either you're fluent and you will have fewer problems doing what you want to do, or you're not, and you're going to spend a lot of time on trivial issues that don't seem to make much sense.

I was in the middle of writing a very optimistic article on how automating your tasks could greatly enhance your workflow and your life in general, and how automation on Mac generally meant "Applescript" when I stumbled on some of those issues when trying to work with Terminal.

I will finish the article because computers are automation systems and using them without trying to automate more than what's provided by bundled programs means letting programs govern the way we work. But that episode painfully reminded me how non-trivial it was for me to work in Applescript, even though I am not exactly a beginner anymore, which does not mean that I know much, just that I know where to look for information when I don't know, and that I can more or less make sense of what I find.

With Applescript, I never read the "manual". I started with online examples, I copy pasted a lot, modified a few scripts, checked the errors, modified again until I got where I wanted, and checked the official reference only rarely (only 333 pages for the PDF I have, but still). And I'm saying to myself, now that I can sort of see how things fall in place, that I should definitely spare some time to go through either the reference or one of the excellent books that are out there.

If Applescript is a language, you're most likely going to use one of its "dialects" too, since any application that supports Applescript actually has a list of words that are specific to it and if the words look the same between applications, they are, like we say in French about some English words "false friends". They look the same but don't always mean the same. Applescript is not a language that you will use to make heavy-duty computations (although you could). Applescript was made to work with "Apple Events", which are used to connect applications together. As you'll eventually read in that other article, one of my script creates a Finder group of folders based on a job request I received in Mail that will end up as a Calendar item.

Applications that don't support Applescript can also be talked to: think about the primitive sign language that we use when we don't know a language. But that can be pretty powerful because just as you can show a person how to click the button that will move a robot, you can also tell Applescript to click on any button or menu item of pretty much any application that runs on a Mac. In fact, some parts of Applescript supporting applications are only available through their user interface, for example, asking a Terminal window to enter full-screen mode requires an Applescript that says "click on such menu item of such menu bar" or even better "hit F while pressing Command and Control" to simulate the shortcut. That's the part that bit me last weekend when I was trying to create a tabbed full-screen window in Terminal opened on the folder that was selected in Finder.

And Applescript can also call the services that are hidden under your Mac's hood: the command line applications that you can usually only access through Terminal, and reciprocally, you can call Applescript from the Terminal. I do that when I select an OmegaT project folder in Finder and use Applescript to tell the command line to use that folder as a parameter to launch OmegaT.

All this is very powerful but can be pretty daunting for amateurs. In my next article, I'll try to show you how I got where I'm at today, which is, in all honesty, not very far ahead of any person who's reading about Applescript today for the first time. I'll publish the Applescript code I'm using, with extensive comments, so that you don't have to just blindingly take for granted what I wrote but get to understand why I wrote it that way. And hopefully that will help you being more productive while working on your Mac.

Update (a few minutes after posting):
I clicked on the "Applescript" tag that's in the column on the right side of the articles, which brought me back to November 2007 when I wrote "I have never found a practical way to use AppleScript in my workflows..." Well, things have changed and now I'm pretty sure I could not live without Applescript on my machine...

References to emails in other applications

DaringFireball has an article on how emails can be linked to in other applications.

Interesting if you need to keep track of clients' mails for a given project. John Gruber even published an Applescript that makes this feature even easier to use.

Popular, if not outdated, posts...

.docx .NET .pptx .sdf .xlsx AASync accented letters Accessibility Accessibility Inspector Alan Kay alignment Apple AppleScript ApplescriptObjC AppleTrans applications Aquamacs Arabic archive Automator backup bash BBEdit Better Call Saul bug Butler C Calculator Calendar Chinese Cocoa Command line CSV CSVConverter database defaults Devon Dictionary DITA DocBook Dock Doxygen EDICT Emacs emacs lisp ergonomics Excel external disk file formats file system File2XLIFF4j Finder Fink Font français Free software FSF Fun Get A Mac git GNU GPL Guido Van Rossum Heartsome Homebrew HTML IceCat Illustrator InDesign input system ITS iWork Japanese Java Java Properties Viewer Java Web Start json keybindings keyboard Keynote killall launchd LISA lisp locale4j localisation MacPorts Mail markdown MARTIF to TBX Converter Maxprograms Mono MS Office NeoOffice Numbers OASIS Ocelot ODF Okapi OLPC OLT OmegaT OnMyCommand oo2po OOXML Open Solaris OpenDocument OpenOffice.org OpenWordFast org-mode OSX Pages PDF PDFPen PlainCalc PO Preview programming python QA Quick Look QuickSilver QuickTime Player Rainbow RAM reggy regular expressions review rsync RTFCleaner Safari Santa Claus scanner Script Debugger Script Editor scripting scripting additions sdf2txt security Services shell shortcuts Skim sleep Smultron Snow Leopard Spaces Spanish spellchecking Spotlight SRX standards StarOffice Stingray Study SubEthaEdit Swordfish System Events System Preferences Tags TBX TBXMaker Terminal text editing TextEdit TextMate TextWrangler The Tool Kit Time Capsule Time Machine tmutil TMX TMX Editor TMXValidator transifex Translate Toolkit translation Transmug troubleshooting TS TTX TXML UI Browser UI scripting Unix VBA vi Virtaal VirtualBox VLC W3C web WebKit WHATWG Windows Wine Word WordFast wordpress writing Xcode XLIFF xml XO xslt YAML ZFS Zip Zotero