In Praise of AutoHotKey
Specific ways to reproduce these AutoHotkey scripts on macOS (a repost of my comment on Lobsters):<p>## AutoHotkey equivalent<p>The closest equivalent to AutoHotkey in general is Keyboard Maestro (<a href="https:&#x2F;&#x2F;www.keyboardmaestro.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.keyboardmaestro.com&#x2F;</a>, currently $36), a proprietary app. In Keyboard Maestro, you define macros using a drag-and-drop scripting language. You can also embed shell scripts or AppleScript. Each macro can have a number of triggers, most commonly Hot Key triggers.<p>## (Keyboard and) mouse shortcuts<p>Keyboard Maestro’s triggers can associate custom shortcuts with your macros. Most of my macros have Hot Key triggers, which capture to keyboard shortcuts. For example, Shift+Ctrl+S triggers a macro that puts my laptop screen to sleep.<p>However, to respond to a mouse input like Scroll Wheel Left, you would have to use a Device Key trigger. A Device Key trigger responds to a single device input, but sadly, it doesn’t block the input from being passed to the OS. In this example, whatever your cursor is over would scroll left in addition to the macro being activated.<p>To replicate the `Send, {NumpadAdd}` part of your script, you would add a Type a Keystroke block to your macro. One nice thing about KeyboardMaestro is it can record the keystroke, so you don’t have to remember names like “NumpadAdd”.<p>If you don’t want to buy Keyboard Maestro, macOS’s built-in Automator (<a href="https:&#x2F;&#x2F;support.apple.com&#x2F;en-ca&#x2F;guide&#x2F;automator&#x2F;welcome&#x2F;mac" rel="nofollow">https:&#x2F;&#x2F;support.apple.com&#x2F;en-ca&#x2F;guide&#x2F;automator&#x2F;welcome&#x2F;mac</a>, free) can be used in some cases. For examples, compare three of the solutions on <a href="https:&#x2F;&#x2F;apple.stackexchange.com&#x2F;questions&#x2F;137047&#x2F;" rel="nofollow">https:&#x2F;&#x2F;apple.stackexchange.com&#x2F;questions&#x2F;137047&#x2F;</a> for working around bad default ⌘C behavior in Books: my simple Keyboard Maestro solution, someone’s straightforward Automator solution, and my shorter, situation-specific Automator solution.<p>## Hotstrings for math<p>I used to use TextExpander ([TextExpander]: <a href="https:&#x2F;&#x2F;textexpander.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;textexpander.com&#x2F;</a>, currently $40&#x2F;year) for something like this. I had `ddate` mapped to the current date, and `solang` marked to a block of markup I used on Stack Overflow. TextExpander implements the direct equivalent to AutoHotkey hotstrings, and is probably the best way to implement short hotstrings like `;a`.<p>However, for my purposes, I realized that I could insert pieces of text more simply by using another program I was already using: LaunchBar (<a href="https:&#x2F;&#x2F;obdev.at&#x2F;products&#x2F;launchbar&#x2F;" rel="nofollow">https:&#x2F;&#x2F;obdev.at&#x2F;products&#x2F;launchbar&#x2F;</a>, currently $30). While its most obvious feature is launching applications, one of its many other features is inserting text snippets. You define text snippets by putting text files in a certain folder. Your defined snippets are then added to your global list of searcheable items, alongside applications you can open and so on.<p>To insert a snippet such as the current date using LaunchBar, I open a LaunchBar window with Command-Space, type `date` to find the “Current Date (ISO format)” snippet, and press Return to insert it.<p>Also note that macOS makes typing special characters easier in general. All macOS keyboard layouts let you access an alternate layer of characters by holding Option. For example, Option-8 types ‘•’. If you would rather Option-A typed ‘∀’ instead of ‘å’, you could set that up by defining a custom math-focused keyboard layout with Ukelele (<a href="https:&#x2F;&#x2F;software.sil.org&#x2F;ukelele&#x2F;" rel="nofollow">https:&#x2F;&#x2F;software.sil.org&#x2F;ukelele&#x2F;</a>, free). I have used Ukelele to define my own keyboard layout “U.S. – Rory custom” that makes smart quotes and apostrophes (“”‘’) easier to type.<p>## Markdown links<p>You could do this with Keyboard Maestro. It has actions for reading from and writing to the clipboard, and for appending to, prepending to, and searching and replacing in text variables.<p>Just a few days ago I implemented a Vim editor mapping to do a similar thing: turn the selected text into a link with the clipboard used as the URL. Of course, it only works in Vim. Here’s the source:<p><pre><code>  &quot; create Markdown link from selected text using URL in clipboard
  &quot; uses vim-surround, so can’t be vnoremap
  vmap &lt;Leader&gt;ml s]%a()&lt;Esc&gt;&quot;*Pl

</code></pre>
## Fast Window Switching<p>I used to have something set up for this. I used Karabiner (formerly KeyRemap4MacBook) to map my fn key to the combination of Shift-Control-Option-Command. Then, with Keyboard Maestro, I mapped ⇧⌃⌥⌘F to open the Finder and so on. That let me type fn+F to switch directly to the Finder.<p>Karabiner was forced to be rewritten as Karabiner-Elements (<a href="https:&#x2F;&#x2F;karabiner-elements.pqrs.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;karabiner-elements.pqrs.org&#x2F;</a>, free and open source) because of changes in macOS, and it lost some features in the process. I haven’t checked if mapping of fn is one of them. I don’t use Karabiner-Elements because I rarely used my fn mappings and my current model of laptop doesn’t have real function keys to remap.<p>As for window groups to switch within, Keyboard Maestro doesn’t have a built-in concept like that. I think you could implement it, though – “if” statements can check the app of the current window.<p>## Remapping the calculator button<p>This would be a straightforward application of Keyboard Maestro.<p>## Scihubize<p>Same as above.<p>---<p>That covers everything in your article as much as macOS software is capable of. You may also be interested in…<p>## Features I use without equivalents in this article<p>Keyboard Maestro lets you define a Quick Macro – a sequence of keypresses and clicks. I can press Ctrl-F1 to start recording, execute a sequence, then press Ctrl-F1 to stop recording. After that, Option-F1 will run the sequence. I use this, for example, in my browser to scroll many adjacent newly-opened tabs down to the start of the content, by recording and replaying the sequence Ctrl-Tab, Down, Down, Down, etc.<p>Keyboard Maestro also supports image recognition for clicking on the screenshotted GUI element or waiting for something to appear on the screen. I’ve used this to make a macro that uses the System Preferences GUI to toggle a setting – it decides whether to move the selection up or down by recognizing the image of the currently-selected preference. I’ve also used it to abort a macro if I don’t see the expected window open after a certain step (which could happen if the GUI was in a certain state), to avoid executing further keypresses in the wrong window.<p>LaunchBar comes with a built-in clipboard history manager. I use this to copy, for example, both a title and URL in one window, knowing they will be saved. Then, after switching to another window, I use the clipboard history to paste both of them where they need to go.