Mac App Store apps must implement sandboxing as of March 2012 - <AUTHOR> http://developer.apple.com/news/

<comment><USER2> Time to settle down, people. This is not the bad news you think it is. Please take the time to read what exactly is entailed in Sandboxing a Mac App before you presume this is a restriction on your freedom. You can start here:

[https://developer.apple.com/library/mac/#documentation/Secur...](https://developer.apple.com/library/mac/#documentation/Security/Conceptual/AppSandboxDesignGuide/DesigningYourSandbox/DesigningYourSandbox.html)

The vast majority of apps on the App store can be sandboxed without effecting their functionality in any way.

Sandboxing on OS X is not like Sandboxing on iOS. You can still access all your files. Your app just can't do it without asking. You can still send Apple events to other apps - you just can't send them to whatever apps you feel like. They must be defined, and permission granted via entitlements. True, you cannot access another applications preferences. However, an application can present an API that other applications can access.

In other words, this change forces apps to be designed much more securely. It reminds me of the Android permissions model.

<comment><USER3> "Sending Apple events to arbitrary apps With App Sandbox, you can receive Apple events and respond to Apple events, but you cannot send Apple events to arbitrary apps."

"By using a temporary exception entitlement, you can enable the sending of Apple events to a list of specific apps that you specify..."

The word at WWDC was temporary exceptions are _temporary_ and just there to ease the transition to sandboxing. I.e. they will be REVOKED at some point in the future.

</comment></comment><comment><USER4> Though there have been many disturbing trends in the evolution of the App Store(s), this one is actually quite mild, if not welcome. Honestly, it's always unsettled me a little that any software can just start arbitrarily scribbling bits to the hard drive. (The system folder is protected, but my data isn't.) The concern is only a little about malware, and mostly about buggy code.

All the sandbox requires is that apps only have access to files when the user initiates the action. And unlike most App Store policies, you're also allowed to request specific exceptions as needed by your app, and I'm expecting they'll actually be reasonable about it. [1] This creates more work for developers, but I think overall these changes will help keep users' data safe.

As also mentioned in this thread, these changes have big implications for inter-app communication. But sandboxing doesn't take the capability away; it just requires devs to do more work, again in the name of user security. There will be a big usability hit on apps which don't see regular updates, and apps whose developers neglect to update this aspect of their apps. But the same capabilities will exist, and eventually most apps will catch up to the new norms.

[1] Although if Apple starts making stupid rejections and standing by them, then I take it all back.

<comment><USER5> > Although if Apple starts making stupid rejections and standing by them, then > I take it all back.

That's a given.

<comment><USER6> Apple typically didn't stand by stupid rejections. They made them, didn't stand by them.

<comment><USER5> We shouldn't have to embarrass a company before we get access to a useful application.

<comment><USER7> We shouldn't have to have a degree in CS and our own testing platform just to see if an application is safe, relatively bug free and isn't going to jack all of our data.

<comment><USER8> Has any application ever "jacked" all of your data? Is the app store really going to debug apps for everyone?

How do over a billion PCs run Windows when there's no app store doing this for them??

<comment><USER9> (Not sure if this is a troll or not, but I'll bite)

"Is the app store really going to debug apps for everyone?"

No, but obvious problems will be detected, and sandboxing will significantly control the damage a poorly-debugged app can do.

"How do over a billion PCs run Windows when there's no app store doing this for them??"

The perception (and in the pre-Vista era, the reality) of running Windows is that you need to be extremely careful about what you download (or even which websites you visit) or you risk data loss, your system becoming unstable, or involuntarily joining a someone's distributed computing experiment.

What Apple was trying to achieve with their app stores (and to a very large degree has achieved) is to allow unsophisticated users to fearlessly experiment with third-party software.

</comment></comment></comment></comment></comment></comment></comment><comment><USER10> This is the only sensible security model for third party software in the world of today. Actually, this is the only sensible security model in the world of ten years ago. Windows has been endlessly criticized for not sandboxing apps. It's gotta be done and Apple is doing the transition the way that has always worked for them: fast and ruthless.

</comment><comment><USER11> The real question is this: Is Apple going to eventually make the app store the _only_ way of installing apps on a Mac? I think this is likely and if so is going to be the end of the line for me as an Apple customer.

<comment><USER4> I draw the line here too. I accept the control tradeoff on iOS because I view them as appliances, not computers, and there are upsides to the curated experience. But if I can't fully control my primary computing device, I'm out. (I'd be okay with the machine shipping in "grandma mode", so long as there's an official way to disable it completely.)

<comment><USER12> Huh? They're just talking about selling things in the Appstore.

They're not stopping people who don't distribute this way.

<comment><USER4> For now. We're talking about a hypothetical future under 10.8+. I don't expect it to change, but neither would it surprise me much.

</comment></comment></comment></comment><comment><USER13> If this means that I can be reasonably certain an application that I purchase from the App Store will be prevented from screwing up parts of my system without my permission - then, as a user, I'm all for it. One day, in the future, apps will run in a chrooted/isolated virtual environment, with some actual guarantees that they are _incapable_ of touching anything but their sandbox, regardless of developer intent. Until that day though, this seems like a reasonable evolution to that world.

Perhaps it speaks to my paranoia - but I've always been unnerved by the concept that an application can basically do anything to the OS that I can from from finder/shell. I have to believe that this sandboxing will reduce the potential for malware doing damage to the OS.

The question I have is - will I be able to give applications like "Backblaze" the ability to read (but not write) from my entire set of user folders? If so, then that's the best possible case. Puts the power to control damage that an application can do in my hands.

<comment><USER14> > The question I have is - will I be able to give applications like > "Backblaze" the ability to read (but not write) from my entire set of user > folders?

Sure. This sand boxing only applies to App Store apps (for now at least). I imagine so long as you can install non-Appr Store apps, you can also have non- sandboxed apps.

</comment></comment><comment><USER15> This SO question raises an interesting issue: [http://stackoverflow.com/questions/7419912/how-will-lions- ne...](http://stackoverflow.com/questions/7419912/how-will-lions-new-security- model-affect-things-like-python)

What if your app uses Python to perform IO? What if you wrote your code using PyObjC? Is there any way to sandbox that, or are you out of the Mac App Store for good?

<comment><USER16> That's a very good question.

I use Python a _lot_ and I combine it with C++ and Objective-C to build a very complex application. While it looks like a regular app and behaves like one, underneath it starts out as a Python interpreter that runs a script and loads compiled libraries. It's a model that works extremely well and I hope it continues to "just work". Sure, it's unconventional and I'd understand if Apple didn't expect most things to work this way, but I hope they don't just break it completely for me.

<comment><USER17> It should work just like for Objective-C applications, it isn't implemented in Cocoa but at a kernel level.

The sandbox has been around since Tiger (or at least Leopard) and with a proper configuration it works fine with Ruby/Python.

</comment></comment></comment><comment><USER18> Apparently, I am not authorized to view any information on sandboxing besides "[a]s of March 1, 2012 all apps submitted to the Mac App Store must implement sandboxing" and that it "is a great way to protect systems and users by limiting the resources apps can access and making it more difficult for malicious software to compromise users' systems."

Apple's developer relations with anyone who doesn't want to fork over $100 just to read the docs are really poor.

<comment><USER19> It's free to register as an Apple developer and your ID will then work:

<http://developer.apple.com/programs/register/>

Though to your point, I'm not sure why Apple requires someone to login just to read the docs.

<comment><USER20> No it isn't. I'm an iOS dev but not Mac and I can't read the docs. You have to pay to read the docs and find out what sand boxing entails. But I suppose if you're not distributing through the App Store why would you even care?

<comment><USER19> You're right. I should have verified that before posting.

</comment></comment></comment></comment><comment><USER21> I wish I could find better documentation for this. I'm curious how their sandboxing implementation will work.

I guess my "membership level" can't see the tech docs.

<comment><USER22> Did you even look? It's publicly available:

[https://developer.apple.com/library/mac/#documentation/Secur...](https://developer.apple.com/library/mac/#documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html)

<comment><USER23> Click top link, follow the "App Sandbox Page" link from Apple's page (<https://developer.apple.com/devcenter/mac/app-sandbox/>), get redirected to <https://developer.apple.com/devcenter/ios/unauthorized/>

</comment></comment></comment><comment><USER24> An I wrong in thinking this sounds like app armor for Linux? A good thing if implemented properly.

<comment> wes-exp Seems so: "In Mac OS X v10.7 and later, placing your application in an app sandbox is a great way to minimize the potential damage caused by successful exploits"

[http://developer.apple.com/library/mac/#documentation/Genera...](http://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html#//apple_ref/doc/uid/TP40010543-CH2-SW6)

<comment><USER25> Putting my applications in a sandbox doesn't really prevent my application from doing exploits because my applications are not malware to begin with. Well behaved applications that are not malware are already not malware. The real issue is what about malware, will this stop them. Well, obviously malware authors are not going to put their applications in a sandbox. They will continue releasing them as before.

And so, obviously, this system won't work unless all software is sandboxed, not just the normal innocuous non-malware that didn't need to be in the first place.

It's the same principal where you can't stop gun crime by banning only law abiding citizens from having guns. You have to completely eliminate all guns or it doesn't work. All or nothing.

To me, this tell me where this is headed. Obviously total sandboxing of everything has to be done for this to be effective at all. And with total sandboxing of everything we no longer have a desktop computer that can be used for general productivity, we have an information appliance that provides a nice consumer experience.

<comment><USER26> Putting your applications in a sandbox prevents you application from being exploited. A bug in you chat software can't be used to get access to your private files anymore. It also prevents that chat software from installing malware on you mac.

</comment></comment></comment></comment><comment><USER27> The end of utility apps? What makes (used to make?) the Mac such a great platform is that apps integrate seamlessly. Making them work together in new ways that were not anticipated by the developer is incredibly powerful (Unix philosophy anyone?).

Sure, sandboxing will allow your app to talk to another app, but only if you request permission beforehand. But what if the app my app wants to intact with has not been written yet?

What about application launchers like QuickSilver, Launchbar, and all the hundreds of other utility apps?

Only allowing sandboxed apps will change the nature of apps that we will find in the app store from "utility" shifting to "just-do-one-thing".

And about the question about whether the Mac App Store will become the only way to install apps on the Mac: the question is not if, but when.

<comment><USER28> This has already sort of happened. Apps are forced to have some sort of permanent presence now. In the past, you could be running many of these and still have a clean menu bar. Now, you have to have an icon for Growl, an icon for Quicksilver...

<comment><USER27> Sure, but that's not restricting functionality. Sandboxing on the other hand will simply mean that those apps won't get into the App Store in the first place.

<comment><USER28> Well, it restricts my ability to have a clean menu bar. Honestly, it's the reason I haven't installed Growl from the MAS.

</comment></comment></comment></comment><comment><USER29> Will this have any effect in practice or will it just be the same as the different _trust levels_ in .NET? The functionality for sandboxing is built in it's just that nobody uses it or knows how to test or enforce it. (with the exception of sysadmins).

In any case i welcome all sandboxing, this is even something i would consider switching from windows because of, given that it actually works out good. Let's take an example from yesterday, i want a simple pdf-merge program. As it is now i have to spend 20 minutes researching a program on forums and other sites before i even install it to see if it's safe and everything. Compared to just installing and see if the result works. This is also why web apps are so popular, you can try hundreds of them with 0 risk for your other data.

</comment><comment><USER30> Now if only they can implement something like this for Safari so that individual browser pages are sandboxed from each other, as is the case in Chrome.

</comment><comment><USER31> I've been making Mac apps for nearly a decade now. I wrote a summary and opinion piece on this:

[http://lacquer.fi/pauli/blog/2011/11/why-the-mac-app- sandbox...](http://lacquer.fi/pauli/blog/2011/11/why-the-mac-app-sandbox- makes-me-sad/)

(HN discussion link: <http://news.ycombinator.com/item?id=3191021>)

</comment><comment><USER3> It's time to write the eulogy for application automation and inter-application communication on the Mac.

AppleScript (beast that it is) was innovative when it was created, and still has not been replaced. Automator is built on AppleEvents, and with sandboxing will come a sharp decline in the number of applications that can receive AppleEvents and the extinction of apps that send them.

<comment><USER32> Not at all!

Sandboxing brings with it XPC, which is an IPC framework for doing very fast and awesome message passing.

It's got some great features for separation of privileges. For instance, you might have an XPC sandboxed process for, say, rendering a H.264 video to a buffer. That process never gets access to the filesystem, the graphics card, or anything apart from the strip of memory that contains the file, and the buffer it has to write its pixels to.

Then you can use this to render a H.264 video in your application, and if a buffer overflow is found that could lead to a video containing shellcode to be executed, you have no fear that bad things can happen to the filesystem or users' stuff.

If I'm not mistaken, I'm pretty sure XPC is how they implemented the crazy feature where you open a QuickLook window on an image or something in the Finder, and if you it the Open with Preview(.app) button, the Finder's QuickLook window turns into a Preview window.

<comment><USER33> /me tries the quicklook -> preview thing

That's kinda cool... never tried that before.

But yeah. Sandboxing does not at all imply not-scriptable. It tends to imply breakage with older systems of scripting, but that's about all, and only until wrappers are made.

<comment><USER3> It doesn't imply it theoretically, but Apple hasn't pointed out a way that scripting is going to be a part of their ecosystem. Apple Events -are- going away. XPC doesn't work like that. What's left?

They could theoretically introduce a newer and better way to do this... Apple Events were far from... well far from usable actually in most cases... but I've seen amazing things built on them. The thought of easy public inter- application communication and automation going away makes me uneasy.

Imagine if Twitter, Facebook, or Google decided to kill all their APIs some time next year... This is like that on a more personal scale.

</comment></comment></comment></comment><comment><USER34> I thought this was supposed to be done by the end of this month?

I'm excited, even if only for the prospect that anything I install from the App Store can't lodge itself everywhere in my system.</comment>


Tell HN: Socialscope does a Reddit - <AUTHOR>

Now that UberTwitter is taken down,Socialscope has opened up their blackberry Twitter app which was in private beta- and they seem to be spreading massively virally. Search for Socialscope on Twitter (See Real-time in Google).  Their followers count on Twitter has more than doubled in less than a day! <comment><USER2> Agreed. Most of my Twitter network is South African and the adoption in our area has been huge.

<comment><AUTHOR> Their followers on Twitter is now 94,000+ . Last week or so they were around 22 K- 23K . Wonder why HN is mostly uninterested in this. While applauding Socialscope guys- this also shows the the high risks of user retention for social networking client developers. You may very well bleed your hard-earned user-base north of 100 K in a couple of days, if the tide is against you. Ouch.</comment></comment>


Show HN: 300Editors – Get Your Writing Proofread in Real Time - <AUTHOR> http://300editors.com

<comment><USER2> I'll be needing this service soon.

Question about the Google Docs add-on: do you have access to all documents on Google docs, at any time?

<comment><USER3> That's great!

Add-on has access only to files in which the add-on is used. More information can be found here [https://developers.google.com/apps- script/guides/services/au...](https://developers.google.com/apps- script/guides/services/authorization#manual_authorization_scopes_for_sheets_docs_and_forms)

In addition your document is shared with an editor, but only after you agree to work with him.</comment></comment>


Puzzle: Apparently blank HN item ... - <AUTHOR>

This link:
http://news.ycombinator.com/item?id=547772
gives me a blank entry.  Any reason?  Or is it just me? <comment><USER2> Looks blank for me too.</comment>


Ask HN: Hand over Project with Profit Sharing - <AUTHOR> Hi guys,
I have quite some free time in the next few months and therefore looking for something new. Recently, I was a software dev at two FAANG companies and co-founded an AI startup. Ideally, I am looking for a person who doesn't have enough time for their SaaS/Project but doesn't want to sell it. I offer to continue working on the project with a 65/35 profit sharing. What do you think about it? Feel free to ping me.
Best, Jay <comment> camping-monitor Sure, I will contact you.</comment>


AMS Open Math Notes - <AUTHOR> https://www.ams.org/open-math-notes <comment><AUTHOR> There's only a dozen or so notes thus far, but it looks like it potentially could be very useful repository.

Found via Terence Tao's blog [1].

[1] [https://terrytao.wordpress.com/2016/12/17/ams-open-math- note...](https://terrytao.wordpress.com/2016/12/17/ams-open-math-notes/)</comment>


PIMPD 1.0 - Perl Interface for the Music Player Daemon - Music is to be enjoyed. - <AUTHOR> http://github.com/trapd00r/pimpd

<comment><AUTHOR> [http://github.com/trapd00r/pimpd/blob/master/pimpd-1.0-scree...](http://github.com/trapd00r/pimpd/blob/master/pimpd-1.0-screenshot.png)</comment>


We are making Columbus a better place – where to next? - <AUTHOR> https://www.billioneffect.com/ <comment><USER2> Sigh.

<comment><AUTHOR> I'd love to draw out as much info from that sigh as possible - what induced that reaction?

<comment><USER3> I know a bit more about this than I can say, but I advised someone to not be involved with this project. It sounded more like a resume builder than something sustainable.</comment></comment></comment>


Rapex - Simple/Innovative/Gruesome way of reducing Africa's rape epidemic - <AUTHOR> http://liad.tumblr.com/post/25149275156/lastchance4sanity-rape-has-become-endemic-in

<comment><USER2> This is a terrible idea. Does the inventor suppose the rapist is going to let the woman go after she's just maimed him with this thing?

Rape is awful. Murder is worse.

(Although it's odd to see this after just reading about the Snow Crash film adaptation - 'dentata', anyone?)

<comment><USER3> Trying to think about it rationally, I can't see the rapist being overly concerned with what happens to the woman, while his penis is trapped in that contraption.

That said, after he gets out of hospital, and is recovered, I can imagine all kinds of horrible things being done in revenge :(

<comment><USER4> That's not a safe assumption (rationally). People often falsely assume that pulling a gun in a confrontation will intimidate the other party. It does not, but instead escalates the scenario beyond recovery.

<comment><USER3> I've heard/read about that (drawing a gun) before alright, but find it genuinely difficult to equate it to getting my penis stuck in one of these contraptions.

I really don't think that, if in this situation, I'd be too concerned about what happens to the woman in question - I would absolutely be thinking about how on earth do I get out of this thing ASSOONASPOSSIBLE without inflicting any lasting damage.

</comment></comment></comment></comment><comment><USER5> There is no "rape epidemic" in Africa. Not according to the U.N statistics anyways: <http://en.wikipedia.org/wiki/Rape_statistics#UN_Statistics>

You should be a bit clearer that you are talking about South Africa and perhaps Congo, and you should also differentiate between reported rapes and extrapolations from small survey samples.

</comment><comment><USER6> This is old news: <http://news.ycombinator.com/item?id=1456632>

</comment><comment><USER7> I think that's a horrible invention pretty much designed to infect women with HIV</comment>


The Internet Is a Series of Lead Tubes - <AUTHOR> http://www.lastwordonnothing.com/2015/11/13/the-internet-is-a-series-of-lead-tubes/ <comment><USER2> The lead pipes are highways. Not "information highways"; literal, people- bearing transportation systems. For a relatively short period in human history, it has been easily possible for just about anyone with a small amount of wealth to _leave_ the place of their birth, to escape those pesky social problems that always crop up in groups, and to do so without a great deal of risk.

...And now the 'net is making the world small again and an awful lot of folks are realizing that they don't like being part of their society any more than their ancestors did. We got our scarlet letters and our witch hunts and our untouchables and our religious wars and it's all ruining our ability to laugh at the ancients because more and more we look at ourselves and see the same failings.

<comment><USER3> The human platform is inherently flawed. We need to build something better.

</comment></comment><comment><USER4> Even without the internet, the status quo in the western world for several decades has been to spend five hours a day eating Hot Pockets in front of the television. Hopefully future generations will remember that when they're criticizing us for looking at too much Facebook.

<comment><USER5> When you factor in the number of people who are going out biking/hiking/vacationing/etc. so they have something to show off to their friends, I think Facebook probably has a positive effect on our collective health. (Present company excepted of course -- we all just love to get outdoors.)

</comment></comment><comment><USER6> "I love the access it gives me to all sorts of information, and how it connects me with people I would have never been able to hear from before. I hate how it also contains spaces for people to easily gather to abuse and harass people." \-- ie. the good thing for him is that people he likes are able to find each other, the bad thing is that people he doesn't like are able to find each other. Sounds rather hypocritical to me.

</comment><comment><USER7> >online harassment

I don't think this is reason enough for most people. I've gotten death threat once. I just didn't chat with neo-nazis after that. People will learn to not attract that stuff.

Personally I find internet consuming because I get this feeling of being social, but I never get my need of socializing satisfied. I can "talk" here sure. But going for a walk with a friend and not talking much feels better afterwards.

But this neither might not matter for the majority of internet browsing people. About 50% of population are extroverst like me.[1] The remainder is introvers. It's likely that majority of internet users are introverts, who have lot smaller need for socializing in the first place.

[1][http://www.myersbriggs.org/my-mbti-personality-type/my- mbti-...](http://www.myersbriggs.org/my-mbti-personality-type/my-mbti- results/how-frequent-is-my-type.htm)

<comment><USER8> Only one death threat? That might actually be enough to drive some people away, but I think the article was talking about people who get death threats on a regular basis. Sometimes just being who you are is enough to "attract that stuff".

The most vulnerable are the ones who don't have friends or a support system nearby. Their only options are to put up with being constantly harassed, or cut themselves off from their community entirely.

[https://amazon.com/The-Internet-Garbage-Sarah-Jeong- ebook/dp...](https://amazon.com/The-Internet-Garbage-Sarah-Jeong- ebook/dp/B011JAV030/)

<comment><USER7> Most people are not idiots enough to hang at notoriously neo-nazi filled irc channel and argue with them. Most people don't get death threats at internet.

So internet is not lead plumbing. It's more like early electric grid, where lightning could burn a house nearby. It's not going away, it will just get better.

That being said internet harassment is a genuine problem. And I don't have solution for it.

<comment><USER8> Death threats aren't the only kind of harassment. Check out the comments on any popular Youtube video, or most news sites that have comment sections. There aren't many of those left actually, because they tend to fill up with ridiculously high levels of harassing and even threatening remarks. Twitter users had to roll their own group-blocking solution (and Twitter has built-in some of these features recently) so communities can collectively compile ban lists. There's just too much shit out there for any one person to deal with.

<comment><USER7> I agree that it's major problem. But I still don't think it's existential problem for internet itself. If some person has to delete twitter account, that doesn't really justify who someone else could not order pizza via internet.

Twitter users are about 10% of internet users. And the problem looks lot worse than it is. Popular users are lot more likely to be harassed, and we are more likely to hear stuff from popular users. Most are probably like me, followed by my mom and one real life friend.

<comment><USER8> I disagree. Twitter, Facebook, email, and other messaging systems are how most people communicate privately and participate in culture. Ordering a pizza slightly more conveniently does not outweigh isolating someone.

You're more likely to hear about harassment from popular users, but that doesn't mean lots of regular people aren't harassed too.

</comment></comment></comment></comment></comment></comment><comment><USER9> The analogy is a bit strained. It's not really the Internet that's harmful, but rather some subset of the humans attached to it. We could cure some of that problem by mandating the abandonment of all online anonymity, but that cure is probably worse than the disease.

<comment><USER10> The author seems a bit focused on trolls and general obnoxiousness, but for me the real problem with such widespread, constant communication is something else. That lends itself to two of the most dominant features of current human culture: the suffocating smallness (or, more properly, _sameness_ ) with which it imbues our world, leaving the probably accurate sense that there's nowhere to run to or hide if you don't like what you see, and the vicious "outrage cycle" that reinforces a particular and very narrow ideology. If you don't happen to agree with that ideology, and there's nowhere you could go instead that's any different (and certainly not any that's better), what's left to you?

It's not entirely fair to blame "the Internet" for this; as Tom Standage has described, earlier forms of communication started these trends. But it really hasn't been until the last 30 or 40 years that communication has been both universal and instantaneous, and those attributes are essential to the kind of feedback loop that creates what we have now. And the worst part of it is that checking out of it yourself doesn't help. The author of this article is absolutely correct on one thing at least: the abandonment will have to occur en masse to make much of a difference.

<comment><USER11> There has always been deviants, and there have always been two kind of deviants: the ones that figure out how to blend with the masses while retaining their identity, and the ones that meet sad ends at the wrong side of a pitchfork.

<comment><USER6> There's always been the third kind, those that would take action to change their surroundings -- either directly, or by surrounding themselves with like- minded people. At least the second method seems to have become much easier with the advent of the internet (first probably too, but that's a whole other subject).

<comment><USER11> Right, I'd considered those to be part of the first group, but the differences are too obvious to not grant a cathegory of their own.

At the end of day, though, it all boils down to claiming a niche in society. If you fill a niche, your excentricities will be tolerated, otherwise you will be labeled as "other" and ostracized.

</comment></comment></comment></comment></comment><comment><USER12> I liked the article. Slowly more and more reach that point on the on-line adoption curve to start realizing some sort of shark jump point exists. In my older age, I've learned its called "boredom", and it's a way of your conscience telling you there is more to life.

Also, gray text on white background promotes illiteracy. Just learn to say no. It's very paux west coast.</comment>


On BART Trains, the Seats Are Taken (by Bacteria) - <AUTHOR> http://www.nytimes.com/2011/03/06/us/06bcseats.html?src=ISMR_HP_LO_MST_FB

<comment><AUTHOR> One word: Stand!</comment>


Creating a bash completion script - <AUTHOR> https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial <comment><USER2> Shell programmable completion highlights how slow the OS community can be to change/improve core tools (shell, coreutils, ttys). Completion should be specified in the binary, and compatible with all shells. A similar interface could be designed for all scripting languages. It was obvious ~20 years ago that it makes no sense for each shell to specify their own completion system, and yet here we still are.

<comment><USER3> This makes sense for some completions (e.g., vanilla lists of options). But often the completion depends on other context that the binary doesn't need to know about. For example, I complete `git grep` patterns based on ctags. There's no reason git should know about ctags; it's only my personal completion that brings the two together.

<comment><USER2> That is probably a very rare case, and any shell-agnostic-completion-protocol could be extensible to handle such a case. But, I think 99% of completions that people want/use on a daily basis could be covered by a machine-readable version of the usual "\--help" option (with support for placement of paths, pids, strings, numbers etc.).

<comment> loa-in-backup If it doesn't work reliably for all cases, there would soon be inevitable need for the kind of scripted completion we have now.

</comment></comment></comment></comment><comment><USER4> I noticed a while back that Debian 9 introduced some strange breakage with bash completion. Previously, if you were typing 'dd if=/dev/...' and started using tab for completion, it would behave as expected. Under Debian 9, typing 'dd if=/dev/' and hitting tab will turn the command into 'dd /dev/'.

I'm sure this was an oversight in the march of progress, but it sure is annoying to see a regression.

<comment><USER5> If this is still an issue, would you mind reporting it?

</comment></comment><comment><USER6> Slowly but surely, I'm replacing half my job with bash scripts. Anything even remotely tedious or error prone, I find that the small investment of time I'm putting in pays off remarkably quickly.

This article? Amazing. My scripts are about to become even more useful and easy to use.

<comment><USER5> I'd recommend trying to move anything fairly complicated into a "real" language - you'll get a lot of libraries, more well-defined and familiar syntax and also won't have to deal with cases like "do I want double quotes here"

<comment><USER7> Or, have your cake and eat it too!

[https://xon.sh](https://xon.sh)

</comment></comment></comment><comment><USER8> I tried writing Bash completion handlers for a Lisp dialect. I couldn't figure out how to get Bash to stop closing quotes, so I gave up on it.

Concretely, here is the behavior:

      $ ./txr -e '(list[Tab]
      (list         (list-carray  (list-str     (list-vector
      (list*        (listp        (list-vec
      0:[0924:142129]:zelenka:~/txr$ ./txr -e '(list-vector'

I continued with _-e '(list-v[Tab]_ and it then produced _-vector '_ including the closing quote!

Clearly, it is oriented toward the idea that each token of the language being completed is a separate command line argument, such as a path name or whatever; it is not clear how to get it to complete syntax that is packaged as a single argument in a quote.

The bash code is:

      txr_complete()
      {
         local target=$2
         local context=$3
         COMPREPLY=($(txr ./txr-bash.tl "$target" "$context"))
      }

      complete -F txr_complete txr

The _. /txr-bash.tl_ file is:

      (tree-bind (target context) *args*
        (cond
          ((m^$ #/-[etpP]/ context)
           (iflet ((match-rng (r$ #/[^ ()\[\]]+/ target)))
             (let* ((pref [target 0..(from match-rng)])
                    (suff [target match-rng])
                    (funs (if (plusp (len pref)) (find [pref -1] "[(")))
                    (boundfn (if funs (fun fboundp) (fun boundp))))
               (mapdo (op pprinl `@pref@1`)
                      (keep-if
                        [andf boundfn
                              (opip symbol-name
                                    (starts-with suff))]
                        (package-symbols :usr))))))))

</comment><comment><USER9> The "real" screenshot, which was done with transparency turned on and displayed parts of what was underneath the shell, was a bit difficult to read.

</comment><comment><USER10> Thanks! I only knew about this linux journal article: [https://www.linuxjournal.com/content/more-using-bash- complet...](https://www.linuxjournal.com/content/more-using-bash-complete- command)

I used it for coding a simple bash completion for Kafka. Code is almost self- explanatory. [https://github.com/igponce/kafka-bash- completion](https://github.com/igponce/kafka-bash-completion) \- just in case someone might find it useful.

</comment><comment><USER11> Nice write up. If you want it down to the point I can recommend this StackOverflow/AskUbuntu answer:

[https://askubuntu.com/questions/68175/how-to-create- script-w...](https://askubuntu.com/questions/68175/how-to-create-script-with- auto-complete)

</comment><comment><USER12> If you care about having nice completions and are able to switch your shell, use zsh. The completion engine in zsh is much more featureful.

</comment><comment><USER13> I created once a completion for a bash function I wrote. Hint: launch npm completion and steal code from there.

</comment><comment><USER14> I would like completion to automatically work on aliases in bash. I use bash over zsh in order to become better at bash programming, but completion of aliases is the main thing that makes me miss zsh. Well that and * * globbing syntax.

(How do I cause two consecutive asterisks to be rendered as such in HN?)

<comment><USER15> > I use bash over zsh in order to become better at bash programming

That's masochism. It's perfectly reasonable to use different interactive and programming shells. I mean, I write most of my would-be shell scripts in Python these days, but I wouldn't want to use it as my main command line (although xonsh is actually quite nice).

<comment><USER14> It's perfectly reasonable, but what's relevant is whether it's optimal. In today's world, with the ascendancy of cloud services and containerization, shell scripting continues to be just as important a skill for software engineers as it was in 2008, 1998, or 1988. And today, the language of production shell scripting is bash. Therefore, using bash in one's personal system is good training for the skills you will make use of in production systems.

E.g. see [https://google.github.io/styleguide/shell.xml](https://google.github.io/styleguide/shell.xml)

> bash is the only shell scripting language permitted for executables.

I'm surprised you choose to write would-be shell scripts in python. I think that a major reason that shell scripting endures is that handling process management and process output is much more work in real programming languages than in dedicated shell languages.

EDIT: But thanks for the pointer to xonsh; that looks fun. Something innovative like that could definitely tip the balance in favor of using that for local shell work and leaving bash as a language one has to know for production work.

<comment><USER15> I write plenty of shell scripts where appropriate, but my main point was really that you don't need to couple your interactive environment to your scripting environment. Sure, write your shell scripts in bash. That doesn't mean you need to use that as your regular shell, though.

<comment><USER14> It's true. My thinking was that there are some techniques that I use in both interactive shell usage and in scripts, and that using the same language for both would teach me them better. I'm trying to think what the best examples are, having run this experiment on myself for a couple of years now. I think one is process substitution with <() and io redirection stuff like <<<.

Also IIRC correctly bash and zsh differ in whether piped commands run in different subshells.

Stuff like that; I'd like to just have firmly in my mind for interactive shell and scripting and not have to know two similar languages.

But I miss tab completion for aliases.

</comment></comment></comment></comment></comment><comment><USER16> This is tangential do the OP but what would it take to send external input to a completion script?

The idea would be to have a different interface to do the auto-completion.

I'm thinking of creating a visual UI through service discovery and providing an easy shortcut sheet to various points of a system.

</comment><comment><USER17> I really wish they would make completion work in BusyBox/Ash. Would make Alpine a lot more useful without having to install Bash.

</comment><comment><USER18> I'm guessing this works with macOS ancient version of Bash, right?

It's been on my todo list for a long time.

<comment><USER19> You should update by installing from homebrew.

<comment><USER18> Yeah, but replacing something as basic as the shell is not a comforting thought. My days of fiddling with the OS are long gone.

<comment><USER20> If you're nervous about replacing your default login shell you can do it just for tmux in your .tmux.conf like:

        set -g default-shell /usr/local/bin/bash

Having competitions on my Mac really makes my day, and every time I complete on a remote host like below, I am still thrilled.

        scp somehost:<tab>

<comment><USER18> That sure is enticing.

Do you mind sharing the needed incantation?

<comment><USER20>
        brew install bash bash-completion@2

The SSH magic lives in: /usr/local/Cellar/bash-completion@2/2.8/share/bash- completion/completions/ssh in a function called _scp_remote_files().</comment></comment></comment></comment></comment></comment>


In Praise of AutoHotKey - <AUTHOR> https://www.hillelwayne.com/post/ahk/ <comment><USER3> I've started[1] to do similar things on macOS using Hammerspoon[2]. So far I've set it up to let me:

1\. Use shift when pasting something to simulate typing in the text instead, getting around websites that block pasting.

2\. Use ";" as a hyper key. By holding it down and pressing another key, I can switch between specific programs without cycling. I can also use hjkl as arrow keys.

3\. Automatically switch audio input and output devices according to my specified priority order. Because macOS would frequently get it wrong, including treating my monitor as a speaker for some reason (it doesn't have built-in speakers).

4\. Make control act as escape when tapped. I use this in conjunction with remapping caps lock to control in macOS system preferences. I previously used Karabiner Elements for making caps lock work as escape when tapped and control when held, but I was able to uninstall Karabiner because Hammerspoon was sufficient.

5\. Disable the insert key because I've never wanted its functionality, but I would sometimes hit it accidentally.

[1]: [https://github.com/dguo/dotfiles/blob/master/programs/hammer...](https://github.com/dguo/dotfiles/blob/master/programs/hammerspoon/init.lua)

[2]: [https://www.hammerspoon.org/](https://www.hammerspoon.org/)

<comment><USER4> Having used both Hammerspoon and AHK, the latter is somehow both terser and more ergonomic. I miss it dearly when I'm not on Windows.

And I actually use caps lock as a "fn" key for hjkl/arrows. Who needs caps lock, really?

I've actually gone kind of crazy with this idea and made my left ctrl, shift and alt behave as fn+ctrl, fn+shift and fn+alt, so that e.g. left ctrl+h actually does ctrl+left. Then I made fn+[ = pgup, fn+] = pgdn, fn+; = home, fn+' = end and fn+\ = delete, with the same augmented fn+LHS modifiers.

Took me about a week for the muscle memory to catch up and allow me to correctly hit ctrl+L with the right hand when I want to go to the address bar, but now I'm ridiculously fast moving around in Excel without having to touch the arrow keys.

Only downside is I have a relatively problematic left wrist and this set up added to the already LHS stress to the already very imbalanced qwerty layout, so it forced me off mechanical keyboards to a low profile logitech right around the time COVID-19 hit.

If only Excel had vim bindings!!

<comment><USER5> > And I actually use caps lock as a "fn" key for hjkl/arrows. Who needs caps > lock, really?

Caps Lock is quite useful, because it's the perfect location for remapping the Ctrl- and ESC-Keys. Which is no surprise, as they originally where located there.

Under linux there is a nice tool for overloading keys, so they behave one way when pressed short, and another way when holded longer. With programmable keyboards you even have it OS-independant.

<comment><USER6> > Under linux there is a nice tool for overloading keys...

Name please (TIA)

<comment><USER5> Oh, right. I knew I forgot something.

I use [https://github.com/alols/xcape](https://github.com/alols/xcape) for some while now. It's old, reliable and straight forward, just does it's job. Only downside is that it seems to be limted to X11. Not sure how well it will play with wayland.

There are now also some alternative tools, with more ability, which allow overloading just on the side. I have them on my list for a while now, but not done much yet with them.

\- [https://github.com/david-janssen/kmonad](https://github.com/david- janssen/kmonad)

\- [https://github.com/mooz/xkeysnail](https://github.com/mooz/xkeysnail)

\- [https://github.com/snyball/Hawck](https://github.com/snyball/Hawck)

Oh, and for rermapping capslock there are also options with X11. I use

       setxkbmap -option ctrl:nocaps

to map ctrl to capslock, then overload it with

        xcape -e "Control_L=Escape;"

to add ESC ontop.

</comment></comment></comment></comment></comment><comment><USER7> I had a low paid data entry job one summer at university well over a decade ago that involved a tortuous process for digitising gas mains installation information. I discovered ahk and found I was able to install it, so I began to script the repetitive entry screens spread between multiple different programs. It allowed you to write a simple GUI form to collect various data up front. There was a lot of window picking and timers and sending of mouse clicks. It was really quite depraved but it worked. I could finish an hour's work in about 10 minutes and spent most of my time listening to Tom Stoppard plays.

I showed it to my immediate manager who I liked; they had a huge backlog and issues with the health and safety executive. She was interested and I thought I might get a slightly better low paid job maintaining my script, but alas the overworked, underskilled, and somewhat frightened IT person couldn't stomach the risk of getting in trouble for using it. So a hundred or so people went back to doing things 6 times as slowly and much more error prone-edly. It's stayed with me as some kind of lesson about inefficient use of human capital.

It was the first time I can remember really solving a problem I had with software. Thanks ahk. You beautiful ugly thing.

<comment><USER8> > It was really quite depraved but it worked

> but alas the overworked, underskilled, and somewhat frightened IT person > couldn't stomach the risk

this seems like a reasonable call to me.

<comment><USER9> Not at all.

He could have written his own program and just used it, and IT would never have gotten involved. Because it was using a 3rd party tool, IT got lazy.

My company, BTW, not only explicitly allows AHK, they actually encourage it. I mean, if you're going to give people compilers to write arbitrary code, this is not worse.

<comment><USER8> It seems weird to expect someone with no programming training (an IT guy) to either build or sign off on something they have no understanding of. In large/high stakes settings, being risk averse and knowing the limits of your understanding are very good traits.

Imho, this IT guy did his job, more or less. What was the testing plan for this AHK script? What edge cases were considered? Unit tests, integ tests.... was there a preprod environment for it? A trial run? Can you safely roll back if / when bad data shows up? What's the retry strategy for network or up/downstream fault tolerance? Is there alarm or monitor coverage for bad scenarios?

I'm not saying a bunch of people typing are error prone, if that's your take on my post. I just think that there's a VERY different set of risks (and therefore mitigations) between a distributed manual process and a large scale automated one.

The IT guy might have on some level recognized this and judged the possible loss to be way more than the "guaranteed loss" of the not-broken current process.

If I were an IT guy with low level skills, I'd be proud of myself for making that hard call.

<comment><USER10> You absolutely do not need all that red tape to use a script written for a well-known program. The IT guy just didn't care to spend the teensiest mental energy to save people an enormous amount of work. "No" is the easiest, safest call possible, not a hard call at all. People like him should be shamed.

<comment><USER8> Spoken like someone who's never caused a prod outage at a real company, I guess. I'd say that - outside of some startup or small company that has few (or no?) users - the cautious approach is right. The IT guy knew that he was a podunk pissant warden of a very, very small portion of very, very large organization (an org of a few hundred people is basically nothing compared to the vastness of many oil companies) and that the value that his org provided was compromised by this automated approach, without knowing how to mitigate that compromise. He made the right call, assuming he was just there as a bulwark against exactly this.

<comment><USER4> There's no "prod outage" here. It was a data entry script.

<comment><USER8> What happens with that data, though? Is this a non production data entry job?

<comment><USER4> Same that would happen with the manual typing process. The workflow either includes a process for auditing data quality or it doesn't, regardless of how it was entered in.

<comment><USER8> Okay, is that a manual process or not? Why not start with automating the testing and not the entry?

<comment><USER11> Because testing is probably not done at all. And even if it was, it isn't the bottleneck in this story.

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER12> I absolutely love AutoHotKey. I've been using it for over 15 years. I used to use it to format my HTML back when i only used a Text Editor (similar to what this link is using for Markdown. I never use my right-control key so I map a lot of stuff to it. I used to have macros on rightctrl+b = surround the selection with  and later  (yes, it was that long ago). I had some nifty ones with logic for adding s (looking for @ and [http://](http://)).

These days I use it for fewer things, but still really useful. One of those is making chat applications that don't offer ctrl+enter to send a message - <USER2> Google Hangouts (basically flopping the functionality):

#IfWinActive Google Hangouts ahk_class Chrome_WidgetWin_1

        ^enter::
        Send {Enter}
        Return

        enter::
        Send +{Enter}
        Return

Another extremely useful is this one, which will type what's on the clipboard rather than pasting it:

        >^v::
        SendRaw %clipboard%
        Return

And when I hit shift also, it does it slow (for input lag situations):

        >^+v::
        SetKeyDelay 500
        SendRaw %clipboard%
        Return

Extremely useful for two main reasons. 1 being input boxes on websites that prevent pasting and 2. certain remote sessions that prevent pasting (like Kesaya or any kind of Console remote application).

<comment><USER13> What are all these websites that prevent pasting? I noticed a few people are using tools to get around these.

<comment><USER14> A common one I see is when you're entering in bank account information and they force you to retype the account and/or routing number, even though you never typed it in to begin with because you just copy-pasted it from your bank's website :/

<comment><USER15> The worst is the banks that don't let you copy it...

I don't understand this insanity around bank account numbers... they should be treated as public info, they're on every single check, anyone you've given a check to has your account number as does your employer...

</comment></comment></comment></comment><comment><USER16> I've started programming using Autohotkey, I just wanted a script for age of empire 2 to manage where catapult can efficiency dispatch attacks. After that I made a bot that can auto fold poker hands, it worked, with AHK you can search image on the screen and get position of the matched image. After that I made a fully functional and autonomous poker bot

many years later I am now a software engineer, I just wanted to manage my catapult on Age of empire 2 ....

So AHK is very powerfull, easy langage and awesome !

<comment><USER11> Yeah. I think it's also a perfect example of scope creep done right. As I understand, its original purpose was closer to remapping Caps Lock to CTRL, not to let you write a whole tiling window manager[0] for Windows in it. But now it can do both, and established itself as the unofficial Windows scripting language.

\--

[0] - [https://github.com/fuhsjr00/bug.n](https://github.com/fuhsjr00/bug.n)

</comment></comment><comment><USER17> I learned programming with AutoHotkey when I was 15.

I first used it to automate grinding gold and items in a simple flash-based RPG for me and my younger siblings around ~2005. At first it just clicked certain locations that buttons would be on a fixed schedule to advance a quest to the end and repeat. But then, being a flash game after all, sometimes it would take a second to load the next screen which throws off the timings and breaks the sequence. So I changed it to wait for pixels to change color as an indication that something finished loading and to start the next sequence of clicks. But that didn't end up being very reliable because the colors & locations weren't always exactly the same, so I updated it to take a screenshot and use it to find the _average_ color of an area of the game where a button would be which ended up being a much more reliable timing indicator. But then it was very slow/used a lot of CPU (and I needed all that CPU to go to running the flash game in a 2005 browser on a 2002 dell), and using a scripting language to sum up 100k pixels every frame just wasn't fast enough. So I wrote a single C function to do the color averaging on a byte buffer, _copied the raw compiled machine code (as hex) into AutoHotkey and directly called it with DllCall_ to get the summed result: ah, much faster. But there was still an unreliable aspect where the position of the game in the browser window and the location of the browser window was fiddly to configure, and my siblings had a hard time getting it set up. It turns out IE used standard windows controls in the browser which (if you look in the right place) exposed the location of the flash bounding box, and with some calculations relative to the browser window I made all the click locations relative to the flash window, which solved that problem. It think it also supported browser scaling because we liked to play it at higher than 100% zoom.

I ended up being more interested in the programming than the game, and my first published project was an array library to make working with associative arrays (where each element is a separate variable myarray1, myarray2, myarray3 etc) easier with insert/delete/append etc operations, before AutoHotkey added true arrays and objects.

Then I went to university for chemistry for 2 years before getting my wits about me and realizing that I would probably be more interested in CS.

<comment><USER11> > _copied the raw compiled machine code (as hex) into AutoHotkey and directly > called it with DllCall_

Holy potatoes, you can do that?! Or, I suppose, you _could_ do that, because I half-expect you can't anymore with all the various security features that were added to Windows over the last two decades. But cool stuff nonetheless.

It reminds me of my own foray into the space of running assembly output; back in my teenage years, I compiled a small bit of assembly into an object file, read it into a C++ program, casted the string into a function pointer and executed. Surprisingly, it worked. I got the idea from StarCraft modding scene; in those days, if you wanted to add a new button for your unit that did something, you had to write the action in assembly, compile it with MASM, and then let StarGraft tool patch the game executable with it (I don't remember if it did it at runtime or modified the actual executable).

<comment><USER17> Yep! Actually I'd bet it still works today. I was able to find it in my Dropbox (2005 me's solution to version control). This is the function that does the dirty work [1]. That gist also has the C source as well. Date modified on these files are ~2008-9.

[1]: [https://gist.github.com/infogulch/d88b956ddd86bd00b351649511...](https://gist.github.com/infogulch/d88b956ddd86bd00b35164951142d533#file- regiongetcolor-ahk-L64)

</comment></comment></comment><comment><USER18> A thousand times, this. I love AHK. It, along with Ditto Clipboard Manager (Yes, I know W10 has its own. It sucks) changes my workflow so much for the better. Some of my favorite examples:

Right Alt becomes Ctrl Tab: Ralt::^Tab

Common typos: ::teh::the ::alreadsy::already

::nopity::Call to undefined function pity()

::awk1::awk '{{} print $1 {}}'

::du-m::du -m --max-depth=1 | sort -n

But it goes waaay behond this. I once used AHK to assist my grandfather, who in his old age had caused him to lose dexterity. He was clicking both right and left mouse buttons at the same time. I used AHK to disable the might mouse button and then mapped right click to Number Pad +. Worked beautifully.

I actually wrote a Big Long Article about it once: [https://www.tidbitsfortechs.com/2013/10/using-autohotkey- to-...](https://www.tidbitsfortechs.com/2013/10/using-autohotkey-to-assist- the-elderly-disabled-and-more/)

<comment><USER19> I'm a bit masochistic when it comes to typos. This is from my AHK script:

        :*:netowrk::
            Send, {Home}+{End}{Delete}
            return

What it does: I have a really bad habit of misspelling "network" that way. I think my right hand is just so _eager_ to get that 'o' keyed in that it doesn't wait for my left hand to hit the 'w' first. So I'm always screwing that word up when typing quickly.

So now, when I make that mistake, I'm punished by having the entire line of text deleted. '{Home}' moves the cursor to the start of the line, '+{End}' is the [Shift]+[End] key to highlight the whole thing, then {Delete} metes out the justice I deserve.

<comment><USER20> You should add a popup that requires you to type in "network" correctly and then issues a Ctrl+Z.

<comment><USER11> > add a system-modal popup that requires you to type in "network" correctly 50 > times in a row and then issues a Ctrl+Z; if you make a mistake, you start > over.

There, fixed :).

<comment><USER19> Working on it. And to make sure I don't cheat, it'll put me into a kiosk mode and temporarily change my password to prevent me from escaping my punishment.

It'll be like my very own ransomware!

<comment><USER11> Be sure the script also temporarily clears your keyboard; can't have you cheating your way out by having "network" ready to paste at any moment!

</comment></comment></comment></comment></comment></comment><comment><USER21> The hotstrings feature is also present in Linux, where they are known as compose sequences. The default compose sequences can be found in the Compose files under /usr/share/X11/locale and you can also have custom compose sequences in ~/.XCompose. Some of the compose sequences make use of a special Compose key (written <Multi_key> in the rules). You may need to go to the keyboard settings to enable the compose key.

[https://en.wikipedia.org/wiki/Compose_key](https://en.wikipedia.org/wiki/Compose_key)

Edit: by the way, these compose sequences also work under Wayland. The only hiccup I found with wayland was that include directives didn't work so I had to put everything in a single file.

<comment><USER22> For more, sxhkd is easy to configure and powerful: [https://github.com/baskerville/sxhkd](https://github.com/baskerville/sxhkd)

<comment><USER23> or just use i3

</comment></comment></comment><comment><USER24> I love AutoHotkey, and it works wonderfully in the niche of writing a bunch of tiny UI- and workflow-smoothing functions, like how an Emacs user gradually builds up tweaks in their config file. The one time I tried to use it for scripting that required more than the most basic logic, I ran screaming back to Python. Over a decade of well-meaning development and reasonable design choices have resulted in AHK growing a syntax Frankensteined together from Basic, JavaScript, and batch script. Thankfully the upcoming AHK 2 is cleaning up a lot of the mess.

[https://www.autohotkey.com/v2/v2-changes.htm](https://www.autohotkey.com/v2/v2-changes.htm)

<comment><USER25> Sounds like AHKv2 is doing the grave mistake of "cleaning up" by breaking all the scripts and work that people have put towards using the tool.

<comment><USER4> Seems to me like we need a 1to2.ahk file

</comment></comment></comment><comment><USER26> Linux users, see [https://github.com/autokey/autokey](https://github.com/autokey/autokey) . I use it for purposes very similar to those described by the article (little automation scripts, text expansion).

It's equally as {sometimes awesome, sometimes infuriatingly quirky} as its Windows inspiration :D , but I guess it's the nature of such a tool :) .

Won't work (yet?) on Wayland, though, [https://github.com/autokey/autokey/issues/87](https://github.com/autokey/autokey/issues/87) .

<comment><USER27> Unfortunately, AutoKey is not similar to AutoHotkey. I tries to be, but fails so far. Lacks a loooot of AHK functionality and contains lots of bugs. The development is so slow that something new after Linux will come out sooner than they reach AHK's state of, say, 2010.

<comment><USER28> In the quest for an analogue on Linux of Autohotkey that exclusively runs on Microsoft Windows, neither autokey nor espanso proved as reliable.

Instead, I derived my own little shell script snippy.sh [1] that expands a fuzzy selected string by letting xdotool type it out.

[1] [https://github.com/konfekt/snippy.sh](https://github.com/konfekt/snippy.sh)

</comment></comment></comment><comment><USER29> Here's what we really need - a tool that monitors the various user actions like specific application functionality used, website actions taken, and maybe keystrokes too (but that gets dicey), and then every month or so it recommends the most frequently done actions that you should automate with AHK or some other tool. What does the community think of this?

PS - I use Alfred and Keyboard Maestro to get functionality similar to AHK on a Mac.

<comment><USER30> It would be the best privacy invading tool you could come up with :)

<comment><USER25> As long as it is only running locally and doesn't send any data anywhere it wont be privacy invading.

</comment></comment></comment><comment><USER31> On macOS a similar tool is Keyboard Maestro ([https://www.keyboardmaestro.com/main/](https://www.keyboardmaestro.com/main/)). I made over 1400+ macros in it over time that automate practically everything for me now.

[https://wiki.nikitavoloboev.xyz/macos/macos-apps/keyboard- ma...](https://wiki.nikitavoloboev.xyz/macos/macos-apps/keyboard-maestro)

<comment><USER32> Would love to have a bunch of macros, but I honestly have a hard time imagining the 1400+ situations that are worth automating? Could you maybe provide some obscure examples of yours? That would be pretty cool.

</comment></comment><comment><USER33> AutoHotKey (in addition to WSL and VS Code) was enough to make me Windows- curious and eventually try a Windows laptop again after 10+ years on Mac.

I first found out about AHK via Tom Scott's similar ode here:

[https://www.youtube.com/watch?v=lIFE7h3m40U](https://www.youtube.com/watch?v=lIFE7h3m40U)

He describes it as "a bodge that helps you make other bodges", which is beautifully put.

[For those outside the UK, a "bodge" is a clumsy hack or repair.]

<comment><USER34> The odd thing about that video is that Tom claims he uses Windows because 1) it is cheaper, and 2) it allows him to "bodge" (aka create quick hacks). And he explicitly dismissed Linux.

But his example, creating an emoji keyboard, would be far easier with Linux. And Linux is cheaper (in terms of money, not necessarily time). Someone in the YouTube comments actually posted how to do it in Linux, which is basically:

        xinput list
        xkbcomp $DISPLAY mapping.xkb
        vim mapping.xkb
        xkbcomp -i <id from xinput> mapping.xkb $DISPLAY

</comment></comment><comment><USER35> Oh man, I am using (abusing?) AHK so hard. I work with legacy software programs for structural analysis, where everything in the model has to be input with clunky form fields. Thousands of properties need to be defined for various structural components (beams, columns, etc). It used to be >2 weeks of entering numbers into fields and clicking buttons.

Now, AHK is set up to just reads my design spreadsheets and define everything in a few minutes. I hate the language syntax, but man is it useful! God bless AHK!

</comment><comment><USER36> I once automated myself out of a job, in my first banking internship, with AutoHotkey. I would fire up a script and then head out to lunch and be done by the time i got back, so then I went home.

wish I got the hint that i might have what it takes to be a developer right then. instead I waited ~6 years climbing the rungs in finance.

<comment><USER37> Man you must have been lucky. The banking interns I've met certainly aren't allowed to leave when they're work is done, that would be ridiculous!

</comment></comment><comment><USER38> One project I did in AutoHotkey is JKLmouse. This is a "mouse keys" program that works on laptop keyboards. I wrote it specifically for ThinkPads, it's not as good on laptops that have clickpads instead of dedicated mouse buttons. (One of these days I will do something about that.)

If you run Windows on a ThinkPad or similar machine, and you ever wished you could have precise pixel-by-pixel mouse movement from the keyboard home row, try it out.

I think it's also a good example of some fairly well-written AutoHotkey code. (Please ignore the messed-up indentation in the SetKeyMap function... Time to add a .editorconfig file!)

I originally wrote JKLmouse as a native Windows app in C using keyboard hooks. But when I saw that I could do the same thing in AutoHotkey it was a big improvement.

[https://github.com/geary/jklmouse](https://github.com/geary/jklmouse)

[https://www.jklmouse.com/](https://www.jklmouse.com/)

</comment><comment><USER39> AutoIt was how I learned to program in 2007! We were using it to control show effects for spaceship-themed exhibit at school!

All the buttons, TVs, lighting effects... all run from windows PCs with AutoIt!

(there was a flash photo gallery, because 2007, but here are some of the images)

[https://www.etc.cmu.edu/projects/lbe/S07/clients/ETC/gallery...](https://www.etc.cmu.edu/projects/lbe/S07/clients/ETC/gallery/images/02.JPG) [https://www.etc.cmu.edu/projects/lbe/S07/clients/ETC/gallery...](https://www.etc.cmu.edu/projects/lbe/S07/clients/ETC/gallery/images/24.JPG)

</comment><comment><USER40> AutoIt ( I know this is about AHK but hear me out) was my first actual coding language. this was way back in 2008 when I was a manual tester and I decided to work on an automation framework around testing our .net based app. the documentation was amazing. the language are incredibly simple. and the windows integration was insane. In a way, if I hadn't worked on the automation framework using autoit, i probably wouldn't have decided to learn python, js and other languages and really wouldn't be where I am.

So, much love to the AHK/Autoit team.

<comment><USER41> I believe AHK was an early fork of AutoIt. AutoIt was my first language as well. A fun language to write code in. No static typing, easy to use. A little code can do a whole lot. I miss the forums, I wonder what ever happened to everybody there, Gary Valik Validator Larz SmokeN -- some names that come to mind. To think of all the devs that used this language as a stepping stone in their careers. Incredible. Hats off to Jon & Team!

</comment></comment><comment><USER42> AHK solved a quirky issue my work had me develop.

We have an excel sheet that gets updated periodically throughout the day by various people. When the spreadsheet is saved it also publishes an MHT file to be displayed on a webbrowser that refreshes every 5 minutes. That browser runs on a little Intel stick plugged into a wall-mounted TV to show the spreadsheet to various parts of the office / production floor.

At night the screens get turned off and through something that happens the little computer thinks the resolution changed and takes the browser session out of its fullscreen view to a tiny square in the corner.

No matter how many setting changes I made it still did it. AHK to the rescue. On a periodic timer take ownership of the browser window and compare its resolution to the desktop resolution. If it has changed send F11, pause, F11 to refresh the fullscreen command and boom, fixed.

That's the first use I had for AHK, I've expanded a lot on that since.

<comment><USER11> Ooh, I'm guessing Windows and its weird treatment of powered-off monitors.

I dual-boot and leave my home PC on for weeks at a time; I just power the screens off when I stop working. My Linux system doesn't even notice; when I come back, everything is at it was. Windows however, the second it notices I powered off one screen, moves all the Windows to the other one. So the first thing I have to do when I come back is to rearrange the windows back to where they were.

I don't know the justification for this behavior of Windows.

<comment><USER43> These might help:

[https://superuser.com/questions/453446/how-can-i-stop- window...](https://superuser.com/questions/453446/how-can-i-stop-windows-re- positioning-after-waking-from-sleep)

[https://answers.microsoft.com/en- us/windows/forum/windows_10...](https://answers.microsoft.com/en- us/windows/forum/windows_10-hardware-winpc/windows-10-multiple-display- windows-are-moved-and/2b9d5a18-45cc-4c50-b16e-fd95dbf27ff3)

Particularly st99's answer on the second link.

<comment><USER11> Thanks!

</comment></comment></comment></comment><comment><USER44> I'm using ahk to record programming tutorials without a typo. It pastes very slowly, one character at a time and it appears as if a person is typing: [https://winkeltriple.tumblr.com/post/177397119146/recording-...](https://winkeltriple.tumblr.com/post/177397119146/recording- code-without-typos)

<comment><USER45> I did this to present how programs works once: Did a medium sized presentation and assembled the program piece by piece, only to have it type it's own source code in the end and run another instance of itself. Confused the hell put of everybody in retrospect, but immensely fun at the time nonetheless :)

</comment></comment><comment><USER46> Something I don't see mentioned in this thread is that Autohotkey is more than just hotkeys. It can also create basic GUIs using native Windows widgets, and is probably the fastest way of producing a GUI on windows (the resulting script can be bundled into an .exe file)

<comment><USER47> Quick Access Popup is a full-blown, highly configurable launcher for Windows. I just started using it last week, fell in love with it, and was shocked to discover it's written in AHK.

[https://www.quickaccesspopup.com](https://www.quickaccesspopup.com)

</comment></comment><comment><USER48> AutoHotKey!!! It single-handedly spurred my interest in software development.

I still remember my favorite scripts and miss them dearly:

\- a smart "spell check" of sorts that could look at previous characters or words to contextually fix typos and expand abbreviations, powered by regex. For instance it would recognize common typos like `AUtohotkey` where your finger would linger on shift for too long. Or auto-add a closing parentheses, if the previous character wasn't a colon (in case you wanted to type `:(` etc.

\- I was a huge fan of OSX and specifically wanted to have something like Quicksilver back then but could not afford a Mac. So I built Quicksilver with AutoHotKey and used that. It had a cache, contextual actions, periodic rescanning, would search not only files but also Preferences and fuzzy search with custom scoring. God I loved this thing.

Fun fact, the current logo was contributed by me waaaaay back in the day :)

</comment><comment><USER49> I thought AutoHotKey was for automatically assigning simple actions to keys. I was so wrong.

I started playing Path of Exile a while ago and soon found PoE Trade Macro ([https://github.com/PoE-TradeMacro/POE-TradeMacro](https://github.com/PoE- TradeMacro/POE-TradeMacro)) which allows you to mouse over items, hit a hotkey to send a web API request to a trade site, pops up an overlay with a pricing summary, lets you adjust certain parameters and search again, and so much more. All allowed by the game in case you're wondering, they encourage it.

There's a YT video in the link above showing just some of the features. And I'm pretty sure newer overlays are even more impressive (I haven't checked them out). AHK is far more developed and complex than I gave it credit for.

</comment><comment><USER50> In a similar spirit, another very useful Windows tool is Windows Keyboard Layout Creator. I first started by editing the US English keyboard to have an AltGr key which produced Turkish letters like ğ and Ş, and just recently I added a Greek dead key which lets me type α, γ, Ω etc with two keystrokes. What's really nice is that the usual keyboard is a single Win+Space away so my friends don't need to struggle when using my PC.

</comment><comment><USER51> Best thing about autohotkey is the minimal boiler plate required and no walled garden approach to welcoming non professional programmers.

Its free, light weight, and has an excellent user manual.

</comment><comment><USER52> Autohotkey is awesome. I used it as part of an automation workflow to remove an hour or longer of daily routine work each engineer had to do each morning as part of their job. Sometimes things failed, but it was used to automate, among other things, a GUI only app.

For "Fast Window Switching":

Linux: Use jumpapp: [https://github.com/mkropat/jumpapp](https://github.com/mkropat/jumpapp)

OS X: Use triggers in QuickSilver: [https://qsapp.com/](https://qsapp.com/)

This is one feature I could not do without in any OS now.

</comment><comment><USER53> Fun AutoHotKey abuse: Tom Scott's emoji keyboard[0]. It's every single emoji (at the time of recording) on 14 full keyboards with 1,000s of hand-placed bespoke stickers. He goes into more detail here[1], but it's beautiful.

[0]: [https://www.youtube.com/watch?v=3AtBE9BOvvk](https://www.youtube.com/watch?v=3AtBE9BOvvk) [1]: [https://www.youtube.com/watch?v=lIFE7h3m40U](https://www.youtube.com/watch?v=lIFE7h3m40U)

</comment><comment><USER54> "Let's start with a simple one. I use Dragon voice to text for writing as I can speak prose a lot faster than I can type."

I often use Siri on my iPhone to write messages, etc. It's pretty good but at times frustrating.

How does Dragon on Windows compare? I like the tablet form factor. Does Dragon work well on a Surface Go?

<comment><USER55> Dragon works much better than Siri for me.

</comment></comment><comment><USER56> One thing I use AHK for:

I bought a logitech trackball, which is great for my RSI, but unfortunately it has no scroll wheel/button, and man, life without scroll wheel and middle click is just impossible!

Luckily, it has 4 buttons apart from the ball, so someone wrote a script to make use of one of those buttons together with the ball to provide the scroll wheel / middle click experience, and posted it on the forums.

Really great that a tool like this exist for this kind of situations.

</comment><comment><USER57> Being too cheap to rent a photo booth for our wedding I used AutoHotKey to glue a software to control my (then) fiancees Nikon and Irfanview together. The software ran on my Laptop, the camera was connected via USB.

</comment><comment><USER58> AutoHotKey was my first programming language, years and years ago on my couple hundred dollar laptop. It wasn't much, but it was definitely a great introduction to basic CS concepts (if statements, loops, functions, etc.).

I remember using it to automate login for a variety of websites, and to automate resource collection for a game I played (Lord of Ultima, in case anyone remembers it).

</comment><comment><USER59> Did nobody else get a TLS (HTTPS) certificate warning for the site? For me it shows it expired 2020-04-26T14:00:00+0200 (I guess that would be pretty crappy for a MITM, unless that's exactly the point since an unknown CA would be more suspicious than someone "forgetting to renew their cert").

<comment><USER60> Nope. The cert I get expires May 20, 2021

<comment><USER59> Same for me now, thanks for checking! I guess a lot of people just clicked past the warning without even mentioning it in a comment until it was updated :| (Assuming that is what happened.)

</comment></comment></comment><comment><USER61> I spent about a year writing a whole library of AHK scripts that could be mixed and matched to completely automate working within a legacy database system. Data entry people loved it and I even had a number of excel integrations for the people who keep everything in spreadsheets. Also GUIs, etc.

It beats the hell out of copy-pasting from one app to the other and hoping you're doing it right. 8 hours of data entry you are bound to make mistakes.

AHK also helped me move into more technical work, so I have a real soft spot for it. However, I am lamenting the move to SaaS websites because not only are there about 3x as many clicks as a native app, but it's really hard to automate with AHK.

</comment><comment><USER62> Fast window switching: pin Firefox in the task bar in the first position (so that it's always the same number), and Win+1 will do roughly what your RAlt+1 hotkey does out of the box in Windows 10.

</comment><comment><USER63> I used this when my mouse started opening more than one tab when I wheel clicked

       MButton::
          If (A_TimeSincePriorHotkey < 150)
             Return
          Send {MButton}
       Return

</comment><comment><USER64> I've been writing AHK code almost every workday for the past year and a half to automate my job and I'm in love with it. The power that I have in comparison to my co-workers in completing tasks is almost unfair. The writer of the article didn't mention GUI's in ahk which are super simple and I encourage you to check them out.

</comment><comment><USER65> AHK is such a good text expander that I came back to Windows for it. It literally saves me thousands of keystrokes a month.

</comment><comment><USER66> I started using AutoHotkey to remap the control groups in Starcraft Brood War.

It was simply too far to reach 6,7,8,9!

Then I used it to make a hotkey to have a popout, always on top, no title bar, browser window. I use that for youtube videos or documentation. Always on top windows + a big monitor are really great for productivity, better than multi monitor imo.

</comment><comment><USER67> I recently wrote a script that I call with Meta+F, assigned via a Linux Mint keyboard shortcut. It will open Firefox, or focus it if it's already open. Multiple presses will cycle through open instances. Meta+T does the same for terminals. It's like a focused version of Alt+Tabbing through programs.

<comment><USER68> For this kind of automation, I use pyautogui, but recently I made a kind of front end for that [https://github.com/rmpr/atbswp](https://github.com/rmpr/atbswp)

</comment></comment><comment><USER69> It's a little different, but I've been using Typinator for this for a long time. In addition to a bunch of default auto-swaps to correct common typos, it has a bunch of built-in libraries for inserting things like Greek characters, arrows, symbols, and emoji. One huge time-saver for me has been in grading: I have to grade student assignments regularly, and I fill out a short text-based rubric chart as I go. So I have a shortcut for it: I type "\\\gt" and I get prompted for the student's name, then it creates a new rubric block with the student's name already inserted and the cursor positioned to start entering scores. Stuff like that is a huge time-saver in terms of wear-and-tear on the arrow keys or moving to use the mouse.

</comment><comment><USER70> I used to play online poker - 17 tables spread over 2 30" monitors. I used auto-hotkey, combined with my MX Revolution mouse - to automate all kinds of things to allow me to play that many tables - raise, fold, go all in, rearrange the tables. It was great.

</comment><comment><USER71> I use AHK so I can have emacs-like text navigation in all apps and not just VS/VS Code. It is extremely liberating to be able to nav/select/delete all from the home row regardless of if I'm in VS, Word, Chrome, FF, etc etc.

</comment><comment><USER72> what? windows is a second class citizen in the wider development world? The "wider" development world covers a lot of areas... though I notice in certain developer communities certain OS's are more dominant.

but yes autohotkey is great!

</comment><comment><USER73> When I played poker full time, it made a huge difference. I was able to manage poker tables with it fully automatically, so I could play on 12 tables comfortably. I was able to implement features that PokerStars didn't have at the time, like hiding the cashier lobby, or floating the Lobby window outside of the screen and float back on mouse-hover so I had more screen-space for tables.

Check out my script if you are interested: [https://github.com/pokerregion/pokerstars- autoit](https://github.com/pokerregion/pokerstars-autoit)

</comment><comment><USER74> My company is trying to solve similar challenges for automating common typing tasks on web pages (email, chat, CRM, etc...) with our Chrome Extension Text Blaze [1].

It was a pretty extensive formula support [2] enabling you to create dynamic snippets. In many ways it's kind of like Excel but for documents.

[1] [https://blaze.today/](https://blaze.today/)

[2] [https://blaze.today/formulas/reference/](https://blaze.today/formulas/reference/)

</comment><comment><USER75> I use AHK to make CapsLock a custom modifier key, mostly to make VIM style movements available everywhere.

Caps+p Ctrl+Backspace Delete previous word Caps+f Backspace Caps+d Delete Caps+h/j/k/l Left/Down/Up/Right Arrow Caps+u/i Home/End Caps+m/, Page Down/Up Caps+e/r Ctrl+Left/Right (next/previous word) Caps+3 Insert current date, e. g. 14.05.20 Caps+Shift+3 ISO format 2020-05-14

I also swapped Return with ' so it's closer to my pinky. Not sure if that was worth it, though.

<comment><USER76> i do something similar using the appskey or printscreen key as a modifier so i so i only have to use my right hand. i used lp;' instead of the usual hjkl vim keys though.

      printscreen::
      thumbMod := true
      return

      printscreen up::
      thumbMod := false
      return

      #if thumbMod

      l::    send {left}      ; move caret
      `;::   send {down}
      p::    send {up}
      '::    send {right}

      +l::   send +{left}     ; select text
      +`;::  send +{down}
      +p::   send +{up}
      +'::   send +{right}

      ,:: send {backspace}
      .:: send {delete}

      #if

</comment></comment><comment><USER17> I learned programming with AutoHotkey. I first used it to grind out gold and items in a simple flash-based RPG for me and my younger siblings. At first it was just timed clicks

</comment><comment> Maha-pudma Autohotkey is the only reason I still use windows at home and it makes work (where I have to use windows) actually bearable.

I have enjoyed reading the comments here, I have picked up some good tips; obvious ones I should have actually thought of.

I am glad I am not they only person who started programming using this language. I have to say that in my limited experience the documentation for Autohotkey is second to none despite that the syntax could use improvement.

</comment><comment><USER77> I love AHK!

It allows me to automate sentences or commands I frequently type. It also helps improve ergonomy of given websites (e.g. "page down" key rather than clicking on "next page").

It avoids the need to download dozens of software to do "this" or "that", piling up in the windows tray. If I need something, I write my AHK snippet.

And of course I have AHK shortcuts to Excel macros. And I have Excel macros that run AHK code :-)

</comment><comment><USER78> I actually built a micro break reminder in AutoHotkey yesterday; every 30 minutes a (top-most) message box shows up, telling me to move and look out a window. The message box auto-closes after 30 seconds.

Extremely simple! [https://gist.github.com/cdaven/360f0509f823d309e1b9de67bd826...](https://gist.github.com/cdaven/360f0509f823d309e1b9de67bd8265b1)

</comment><comment><USER79> I had an AHK script that uses capslock+ijkl for navigation (plus a few other things like modal space-bar for select) but it wasn't reliable enough at speed. Maybe it was the way I programmed it.

So I wrote a Windows keyboard hook in C which turns out to be easy enough to do. I just hard-coded the key mappings in a switch statement. Been using it for about 10 years and find it hard to work without it.

</comment><comment><USER80> I heavily use AHK to make my Windows 10 an enjoyable and keyboard focused environment. Between AHK and an hardware keyboard with full keyboard macro's, I have Windows working with my Macintosh inspired keyboard bindings.

Of course on the Mac, I heavily use Keyboard Maestro and LaunchBar so I am really implementing my own keyboard centric UI

<comment><USER81> > hardware keyboard with full keyboard macros

Do you use one? Which? I used one, very convenient, in eighties(!) and haven't seen something comparable since.

The functionality I had then that I liked was: any key could be programmed to really anything else (except the special "macro" key) -- another key or another sequence of the keys, and I regularly did some action once, recording it with just one "start recording" and one "stop and assign to.." action and after that just "playing" it when needed. It was a huge time / nerves saver at these times, especially because it was fully independent of the programs and even of which OS I've used (I've had to switch between two even then).

<comment><USER37> I'm not the parent, but I use the Kinesis Advantage and it supports macros. Basically you can rebind any key to any other and also bind any key to a sequence of other keys. I think you can also change the timing of each key press, but I've never used that feature.

</comment></comment></comment><comment><USER82> This is a great tool I use all the time. In addition to about 2 dozen hotstrings, I have a script that will automatically open my email editor, a script that will open my calendar to allow me to schedule a meeting, and a script that will open a new message in Slack to allow me to quickly fire off a message.

Huge time saver!

</comment><comment><USER83> I used AHK to create my personal snippets tool which works across all IDEs, editors, browsers, etc.

Have been using this for years and years and finally published to GitHub a couple of years ago.

[https://github.com/ethanpil/snips](https://github.com/ethanpil/snips)

</comment><comment><USER84> Oh god, I remember EMC made us use this to manage their god-awful support system.

One of the worst experiences of my life in IT. Not the fault of AutoHotKey but they used it to paper over the cracks in their massively flawed and sucky support system. The only thing I've used that is worse than the SAP GUI.

<comment><USER85> The AHK scripts you mention was probably the work of somebody who automated himself out of a job. Now upper managment thinks they would save $$$ by maintaining the AHK scripts instead of the actual underlying support system.

<comment><USER84> No, he was promoted and fated. Those scripts required maintenance!

</comment></comment></comment><comment><USER86> AutoHotKey scripts gets me some pretty insane lee-sin ward-hops so yeah its a pretty awesome tool.

You can mess with league of legends folks a lot with it actually. You can use it to spam 5 pings around someone instantly. You can spam emotes with it. You can write messages quickly in chat.

</comment><comment><USER87> AHK was how I got back into programming. I wrote some scripts to help reduce RSI playing online poker and then later when I worked in a call center wrote some scripts to automate dialing my phone and macros for basic notetaking.

A clunky as it is, it is a fantastic tool.

</comment><comment><USER88> I've used AHK a fair bit, and while it's quite helpful I can't help but want for a better syntax and less limited core language. I think it would do much better as a lisp with more obviously defined syntax boundaries.

<comment> frosted-flakes Try the AHK v2 alpha. It removes a lot of the cruft and weird inconsistencies of v1. Someone else on this page linked to a changelog.

</comment></comment><comment><USER89> I have been a big fan of Macro Express which has a GUI so if you aren't a developer, you can build Macros. Never used AHK myself. Anyone used both that can comment on strengths of AHK vs Macro Express?

</comment><comment><USER90> I would like to see much more work on "Generic Scripting Hosts", like ActiveScripting (MS) and OSA (Apple)? But since everybody develops into the cloud, goodbye elegant user experience...

</comment><comment><USER91> The AHK script that has saved me the most RSI is mapping Caps Lock to double- click. Sounds weird, but didn't take long to pick up, and has saved me uncountable mouse clicks.

</comment><comment><USER92> I don't use much of AHK, but I love it.

[https://www.2uo.de/my-autohotkey-script/](https://www.2uo.de/my-autohotkey- script/)

</comment><comment><USER93> I remember back in 2005-2007, using AHK to make data entry way more efficient, at a few different companies. It's also great for macros in video games.

<comment><USER41> Pretty sure AHK/AutoIt made its way into many legitimate products despite its binaries being false-positively flagged by anti-viruses

</comment></comment><comment><USER94> I use Autohotkey to set up my tmux bindings when working under WSL, it's gotten my WSL environment nearly up to parity with an OSX iterm2 environment.

</comment><comment> jerome-jh Certainly Alt-Tab is annoying. In Ubuntu (default install) they even so dimly highlight the selected window they completely screw up the functionality.

</comment><comment><USER95> I can tell you that this program is so useful, automated everything in my system to be able to use it more smoothly and have saved a lot of time.

</comment><comment><USER96> I am using AHK on Windows for ~10 years now. Does anyone know of a linux equivalent?

<comment><USER97> I think it works on Linus as well, doesn't it?

<comment><USER96> There seems to be a Linux version called Autokey, indeed.

</comment></comment></comment><comment><USER98> i used to use autohotkey for lots of stuff until steam started banning me from paying games; they won't disclose why (ugh) but ahk seemed to be what was triggering the false positives :(

</comment><comment><USER99> Does anyone know if using AHK increases input latency at all?

<comment><USER18> In some programs, yes. I've found it works _horribly_ in Notepad++.

</comment></comment><comment><USER100> Specific ways to reproduce these AutoHotkey scripts on macOS (a repost of my comment on Lobsters):

## AutoHotkey equivalent

The closest equivalent to AutoHotkey in general is Keyboard Maestro ([https://www.keyboardmaestro.com/](https://www.keyboardmaestro.com/), 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.

## (Keyboard and) mouse shortcuts

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.

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.

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".

If you don't want to buy Keyboard Maestro, macOS's built-in Automator ([https://support.apple.com/en- ca/guide/automator/welcome/mac](https://support.apple.com/en- ca/guide/automator/welcome/mac), free) can be used in some cases. For examples, compare three of the solutions on [https://apple.stackexchange.com/questions/137047/](https://apple.stackexchange.com/questions/137047/) 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.

## Hotstrings for math

I used to use TextExpander ([TextExpander]: [https://textexpander.com/](https://textexpander.com/), currently $40/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`.

However, for my purposes, I realized that I could insert pieces of text more simply by using another program I was already using: LaunchBar ([https://obdev.at/products/launchbar/](https://obdev.at/products/launchbar/), 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.

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.

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 ([https://software.sil.org/ukelele/](https://software.sil.org/ukelele/), free). I have used Ukelele to define my own keyboard layout "U.S. – Rory custom" that makes smart quotes and apostrophes (""'') easier to type.

## Markdown links

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.

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:

      " create Markdown link from selected text using URL in clipboard
      " uses vim-surround, so can't be vnoremap
      vmap <Leader>ml s]%a()<Esc>"*Pl

## Fast Window Switching

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.

Karabiner was forced to be rewritten as Karabiner-Elements ([https://karabiner-elements.pqrs.org/](https://karabiner-elements.pqrs.org/), 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.

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.

## Remapping the calculator button

This would be a straightforward application of Keyboard Maestro.

## Scihubize

Same as above.

\---

That covers everything in your article as much as macOS software is capable of. You may also be interested in…

## Features I use without equivalents in this article

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.

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.

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.

</comment><comment><USER101> This software got me through a really rough hurdle in my earlier years. Had to automate data capture from an accelerometer on a Windows machine. You could only initiate the intended capture from a UI, so automating this for an assembly line testing jig was going to be a real hassle if not for AHK.

Remarkable piece of software. Wish something like that was for *nix.</comment>