Hacker News new | past | comments | ask | show | jobs | submit login
In Praise of AutoHotKey (hillelwayne.com)
414 points by todsacerdoti 13 days ago | hide | past | web | favorite | 212 comments





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

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


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!!


For Excel on Microsoft Windows, there is vim_ahk [1] to add Vim key bindings (after adding EXCEL.EXE to VimGroup) using AutoHotKey. For LibreOffice, especially its spreadsheet calculator Calc, there is the vibreoffice [2] extension.

[1] https://github.com/rcmdnk/vim_ahk#applications [2] https://github.com/yamsu/vibreoffice


You can use Quick Actions (formerly Services) to trigger Mac automations, with customized Keyboard Shortcuts and text input replacements but it’s all scattered across a dozen apps and it’s kind of clunky to piece a workflow together from all these parts. But if you know the ins and outs, there’s a lot you can accomplish from a Mac, particularly as macOS has historically had better app support for AppleScript and somewhat better accessibility tooling. http://www.macosxautomation.com/automator/services/extension...

Recent attempts to lock down the system point to how it’s “not the default” to customize your Mac outside the App Store. And I find the share sheet is still more useful on iOS than on macOS (for now?) just as Finder is more useful on macOS than Files app is on iOS.

That said, Windows Terminal and WSL highlight that Microsoft isn’t slowing down here and Apple might actually need to play catch-up at some point and evaluate new approaches to developer and power user pain points. (AppleCare-supported upgradable storage is on my wish list but that’s not technically the software’s fault... just a policy Apple used to have and then later removed from their website as they moved to proprietary SSD controllers)


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


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

Name please (TIA)


Oh, right. I knew I forgot something.

I use 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/mooz/xkeysnail

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

oh yeah. i remapped it to f15 and use it all the time now

> including treating my monitor as a speaker for some reason (it doesn't have built-in speakers).

This is quite common on HDMI monitors. Since the HDMI connection transmits both audio and video, the monitor just accepts both audio and video input. They would then have a 3.5-mm jack to allow you plug in an actual speaker or headphone to receive the audio output.


Which is something I don't understand, just separate the signal and give me a digital output from the monitor, why are monitors doing digital analog conversion for audio too, all of a sudden?

It was useful for me when I hooked my nephew's Nintendo Switch up to my computer monitor to let him play and then connected desktop speakers straight to the monitor.

It's pretty cheap to add and enough people find it useful

There are usually different flavors of the same base-model. Some have speakers, other not. Not adding speakers, but leaving the rest ist just cheaper and more reliable than tinkering with every flavor for single features.

Ah, that makes sense. Thanks. I just checked and realized that I forgot my monitor has a headphone jack.

The usage of ; as a hyper key is fascinating. This is the first time I've seen someone do something with Hammerspoon that's actually tempting me to try it out.

For paste blockers I've been using an Alfred workflow that types keys using AppleScript. It doesn't work with characters that require special input like ü, which is annoying, but it's sufficient for passwords. The benefit here is I'm not using up a global hotkey for such an infrequent use-case (especially not one actually used by other apps, such as Terminal.app).


Using ; as a hyper key blew my mind, like the article recently about how a certain developer calls all of his scripts ',something' so if he want to run a cli command of his, pressing comma then tab will show only his scripts, so ',py(tab)' won't have 15 pythons in it.

I had almost used up all combinations of Ctrl, Alt, Shift, Win and letters at one point, and still never thought of making my own hyper key. It's genius.

At my new job I'm afraid to download AHK at all :(


There is a portable version of autohotkey, so you can run it without installation if this would ease your fear.

It's been a bit since I've last used AHK, but I believe you can also compile your script to .EXE and just take that to work with you.

Karabiner Elements is really popular for this use case. I have Caps set to be escape when pressed and Hyper in conjunction with pressing another key.

The downside is Karabiner Elements requires installing a kext, and macOS Catalina periodically shows warnings saying the kext is a legacy extension.

Man as someone who has been putting off the upgrade that's too bad, I figured their solution of creating kind of a virtual keyboard input would be pretty solid going forward.

Does Hammerspoon work just as well? Karabiner is so incredibly solid.


Hammerspoon is doing the stuff talked about here using event taps. I don't know if you can reliably use event taps to simulate different modifiers though, or to prevent a modifier from actually taking effect (e.g. if you wanted to remap one modifier to another).

I'm hoping Karabiner Elements figures out some solution going forward. It still works on Catalina but the expectation is the "legacy kext" will no longer function on 10.16.


Why macos doesn't offer something like this by default is beyond me.

Really, there are some really smart people at apple. You know some of them have customized their environment. You know apple has internal tools.

Why don't they get it and support customization of their os?

They're also not very supportive of "outside" tools. Say you want to use python on macos. Apple has only the most passing support for it. Same with bash or anything else that could put up a dialog box or whatever without having to compile/use xcode/other barrier to entry.

applescript doesn't count.

I know you can add software like macports or homebrew, but I mean first class support from apple.


I really need to look at Hammerspoon, thanks for the pointer.

Talking about automation, I use BetterTouchTool[1] to give me a few useful touch bar icons:

- Speaker and headphone buttons (using switchaudio-osx[2])

- Start meeting that starts a Zoom call and adds the link to my clipboard

- Write email that gives me a new blank email (and makes it visible)

[1] https://folivora.ai/

[2] https://github.com/deweller/switchaudio-osx


> getting around websites that block pasting.

This one really drives me mad. Is there really any legit reason to this?

By the way my hack is I paste it in the address bar, then just drag-drop into the field. Works 50% of the time or more (fails when a lot of these stupid websites don't use placeholder attribute but rather use some sort of Javascript for the placeholder text)


>> getting around websites that block pasting.

> This one really drives me mad. Is there really any legit reason to this?

No. Which is why I set the about:config option "dom.event.clipboardevents.enabled" in Firefox to false. That turns off the ability of websites to block pasting in Firefox.


Oooh, neat! Thanks! I presume it would also defeat those idiotic "let's insert a backlink or an ad into the text you just copied" scripts.

Truly, there are very few legitimate reasons for a site to even know you've copied or pasted something. Makes me think this setting should be a whitelist.


> This one really drives me mad. Is there really any legit reason to this?

Yes, preventing you to steal their content.

Of course this only works against the technical layman, who does not even think about googeling for a solution to this.


I use one site that completely unreasonably blocks paste with Ctrl+V. The Paste context menu item works, though, so I use `Menu P` instead of Ctrl+V.

When I had a work-Mac I used Keyboard Maestro for stuff similar to this. It can do stuff based on a variety of input events; I had it do "location-y" stuff for me upon wake so it would do different things based on if it woke at the office or at my house, for example.

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

Did you overload the ;-key, meaning it sends ; when pressed fast, and acts as modifier when hold and pressed with other keys? Is'nt that kidna painful to use and inflicts false input occasionaly?

I too have some personal modifier-keys. I remaped Pause-key to the Right alt-key, and use for persional settings in apps. And I remapped the left Alt-key to F22, and use it for window managing and staring/raising apps.

Benefit with this is that both keys are exclusively used by me and the pause-key is also available even when my setting is not available.


That's correct, but I've never gotten false input before. If my setup gave me false input even 0.5% of the time, I wouldn't use it at all. I give myself 250 milliseconds to release the ; key to type it as normal, and that has worked fine for me, both on my laptop keyboard and on my external keyboard.

I find it very easy to use since my pinky finger sits on the ; key by default.


Although really intreaged to finally find some really good use for Hyperspoon something in that script didn't work. pressing ; and releasing it kept the hyper active so if you pressed some trigger key it triggered it instead of doing the input. Also pressing ; repeated did of course nothing.

Wished there would be a better way to actually map hyper key that only is activated if pressed down. Well, I went back to BTT and setup fn + and this works too.


Thanks for sharing the dotfiles!

I use combination of BTT, Karabiner Elements, yabai and skhd to do remappings but this comment has intrigued me to give hammerspoon a shot!


What was wrong with Karabiner Elements?

I am using it and am curious what are the downsides


I happily used Karabiner for years but only to handle my caps lock remapping. It's not bad. I just generally like having as few dependencies as possible. I definitely needed Hammerspoon for other stuff, so if it can cover my one use case for Karabiner as well, then I only need to use one program instead of two.

One specific reason I want to go with Hammerspoon in the long run for key remapping is that I plan to do more complicated things, like setting up key layers. And even if that's possible with Karabiner, I'd rather maintain the complexity with Lua code rather than Karabiner's JSON configuration, which is complicated enough that someone created a separate tool[1] just to generate the configuration.

I should note that one of the maintainers of Hammerspoon specifically recommended[2] using Karabiner instead of Hammerspoon for key remapping because Karabiner was built to do that. Hammerspoon has a much higher level view of key events, from what I understand. I don't plan to do any remapping with modifier keys though. I plan to only use the letter keys for everything. Something like: press and hold ;, then press and hold v, and then tap a. And that will re-arrange my current windows into my preferred arrangement. Stuff like that. Based on my initial experience, I should be able to do everything with just Hammerspoon.

[1]: https://github.com/yqrashawn/GokuRakuJoudo

[2]: https://github.com/Hammerspoon/hammerspoon/issues/1025#issue...


I've used Karabiner, BetterTouchTool, and some window management tools. It looks like hammerspoon can replace all of them.

The ; idea is great, I will try it with BetterTouchTool.

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.


Awesome. And gross. And awesome.

I did something similar around the same time parsing out some archaic TSV format. I forget the details of it all but we were copy-pasting from Notepad to Excel which I think involved changing some Notepad word wrap preference with every file? I think the objective was to get a CSV file and then FTP it somewhere?

Anyway, I wrote a powershell script I think it was, maybe I managed to install python? Whatever it was I basically replaced myself with a shell script and spent my spare time posting on somethingawful. Which actually did lead to a better job interview. Overall a good use of my time.

I hadn't thought about this for years. Thanks for reminding me, I think.


Its experiences like this that make me sad for people who can't code. Not full blown dev, just enough to automate the mundane.

I can't imagine being at the mercy of computer tech in areas of being the master of it.


What advantage is it to the grunts if you automate stuff such that what took them an hour takes ten minutes? All that will happen is that either some will be laid off or the boss will find other ways of filling the time with other work.

Tedious work is very unpleasant. It's not just about how much time things take, but about how dreadfully boring the work can be.

Less mouse arm pain. And you can listen to podcasts, or something, in the 50 minutes.

Your mistake here was not pitching the idea to someone more senior.

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


Perhaps. It certainly wouldn't have been me that had to live with it. It might have been hard to stop using it.

To give some context this was a utility company. The gas pipes were consumer and commercial supply lines. You need to know where they are buried so people don't blow themselves up digging them up. It was safety critical.

>> It was really quite depraved but it worked

The baseline context for this, though, is a very error prone process. It was common for me to register a pipe in the technical specification (size depth etc) system and map that (by rekeying the handwritten ID) and accidentally pick a different location in the system for indicating connection of service to main pipes. You could have a service pipe (to someone's house) registered to a main in a completely different area. My script eliminated these types of errors.

The other thing to note is it didn't change the underlying process. You could, and I did, check the underlying form fills (something I wouldn't bother doing when it took 6 times as long).

I'm not trying to denigrate the individual here, he might have been doing his best given his knowledge and level of autonomy (he might also have been chickenshit) but as an organisation they let some value fall on the floor from an employee because they had no mechanism to capture and integrate it.


If it really reduced the required time six fold, the obvious safety-productivity win-win would be to independently (ie different workers) enter everything twice. You would enjoy a three fold improvement in time requirements, should nearly eliminate all basic data entry errors, and would significantly improve the employee experience. Or you could just decide to pass on all that, that's always an option I suppose.

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.


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.


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

Which raises the question, why does such a person even have the authority to make calls on what software can or can not be used within the company? You shouldn't have the right to make these kind of decisions without basic understanding of how software works (beyond "I click stuff and things happen, magic!").

> 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?

Without understanding of how software is built, those are questions the IT guy can't possibly ask thoughtfully. They become a mere checkbox ticking exercise. And most of them don't apply anyway.

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

It's not a hard call. It's the easy call. The ass-covering, responsibility-mitigating, work-minimizing, consequence-free default deny call.


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.

"Shamed", come on. You don't ask the guy in charge of maintenance to validate new tools. That person's job revolves around stability, and they will always make the safest possible call.

If a new tool is needed, a steering committee of some kind should be used, and IT will be one part of that.


Where I work, IT in general has little say about what tool I use on my PC. They do periodic scans to check that I don't have any known unsafe tools, or tools that are known not to be OK without a formal license. But otherwise, as long as I'm not violating a license and not circumventing my virus scanner, I can use whatever tool I want.

Work would come to a crawl if IT had to validate every single tool used in our company. The notion that this is within IT's scope is flawed. It's the equivalent of asking a government agency to vet every single product that is produced by any company for consumer safety in the whole of the United States, and then rejecting most of them because of the lack of resources to thoroughly vet them.


Would they get in trouble when someone used an automation tool that submitted hundreds of thousands of empty or even worse completely incorrect records, with no reconciliation plan?

If so, then they're completely right to stop some novice programmer from bringing their scripts to bear. There's no reason to take that risk if they have the funding for the current human solution. Bring it up to the superiors and pitch it, talk to some devs. I've seen groups lose hundreds of millions of dollars when one of these excel vbscript python enthusiast AHK things go off the rails. It's a mess, and - again - risk aversion is the most reasonable stance from a business standpoint. He's not a hacker founder, he's a business IT manager.

Edit to say, it sounds like you work at a company with <500 engineers, maybe even <500 employees total. That's fine! It's good even, but it's not an experience that's easily exported to the realm of Actual Business, at least not exactly. As a consultant, I've had billion dollar companies that need the fast fix (python script with a csv datastore to keep some account info or whatever) and I've worked for companies where this sort of approach would get you insta-canned. They're both right enough, but assuming one size fits all is absolutely crazy. It sounds like the mega oil corp above was the latter, at least to me.


> Would they get in trouble when someone used an automation tool that submitted hundreds of thousands of empty or even worse completely incorrect records, with no reconciliation plan?

As I said in my comments above, it's a question of who owns the data. In general, other than things like financial information and HR records, IT does not own the data in our company. They provide lots of services (version control, Jira boards, etc). They often are responsible for backing them up at a specified interval (daily, etc). And they are responsible for configuring them to be secure (which may involve shutting off APIs). But they don't own whether someone can write a script to automate clicking on fields, etc.

They don't own the data and outside of the agreed backup are not responsible for it. They absolutely would not get in trouble if someone automated something that destroyed that data. The policy is "We provide the service, but you are responsible for what goes into it and how." They do not need to see that we've vetted people's scripts for bugs, etc. They expect us to be responsible. If the data is lost, we will be in trouble, not them.

If IT was responsible for every database, Jira board, etc in the company beyond their regular backup, little work would be done. It's a huge company, and we cannot have one org be a bottleneck.

At times they do need to put some restrictions, but even in those cases, the department is free to get their own hardware and run their own database/JIRA board/whatever. There are a few security requirements to hook it up to the network, but IT will not get in our way if we set up our own Jira board/DB. They'll just tell us that we are responsible for backing things up nor will they provide support if we break things.

This is why my company has lots of pseudo-IT teams across departments. The company wide IT is responsible for the big things. The smaller pseudo-IT teams exist to be more flexible and not be constrained. They don't exist in defiance of IT - IT actually endorses it.

> I've seen groups lose hundreds of millions of dollars when one of these excel vbscript python enthusiast AHK things go off the rails.

But why is IT responsible for it? Perhaps in your company this is in their purview, but not in ours. And I'd argue that it shouldn't be. IT cannot go into every org and police what VBA scripts people use, and if they did they'd likely do more harm than good. While you may have seen losses of hundreds of millions of dollars, I'm pretty sure the gains from Excel VBA scripts is much, much more.

> Edit to say, it sounds like you work at a company with <500 engineers, maybe even <500 employees total.

Nope. Well over 50K employees, with over 60% of them being engineers. Likely the top company in the field we're in.

No one has answered my question that I brought up several times: If I can write my own program to do it, should they ban compilers as well? I'm sorry but whatever damage a VB script can do can also be done by C#. Should we ban Visual Studio?


> As I said in my comments above, it's a question of who owns the data. In general, other than things like financial information and HR records, IT does not own the data in our company. They provide lots of services (version control, Jira boards, etc). They often are responsible for backing them up at a specified interval (daily, etc). And they are responsible for configuring them to be secure (which may involve shutting off APIs). But they don't own whether someone can write a script to automate clicking on fields, etc.

I don't understand what that means. With noted exceptions, nobody owns specific data in any of the many companies where I've worked or consulted. You own data stores, get restricted access to other data stores... that's services, even if it's SOA/P. Standard for many many years.

> If IT was responsible for every database, Jira board, etc in the company beyond their regular backup, little work would be done. It's a huge company, and we cannot have one org be a bottleneck.

Not sure what this has to do with the situation at hand, where a user who was a part of a human data entry team dealing with metrics around oil rigs and live oil pipeline data decided to automate their data entry dayjob. No data stores or backups were touched beyond their contribution.

> No one has answered my question that I brought up several times: If I can write my own program to do it, should they ban compilers as well? I'm sorry but whatever damage a VB script can do can also be done by C#. Should we ban Visual Studio?

I don't understand your insistence that a language is meaningful. Why would the IT guy sign off on a haskell program, or a java program, or a python or awk or bash pipeline? He doesn't have the expertise to verify that it does what your job is to do. He doesn't know the guy's job, doesn't see testing, can't verify if it's right or not. With no verification of correctness, he's completely right to block it, no? I almost feel like I'm missing something here.

Sure, my employer allows me to run whatever I want on my laptop. They don't let me pump piles of data into prod environments from that laptop even if it's done in AHK, F#, ... whatever. Why would they? That's a crazy requirement to have.

If you have over 50k employees and each person is allowed to script prod data, let me know the name and some prod endpoints for your company. I'll give you a hundred bucks on the spot :)


> Not sure what this has to do with the situation at hand, where a user who was a part of a human data entry team dealing with metrics around oil rigs and live oil pipeline data decided to automate their data entry dayjob.

You keep bringing up the oil fields, oil pipeline, etc. The original commented did not indicate that this is the purpose, and nor did he indicate the importance of said data, or the cost of the loss. I think I have an idea to what he is referring to, and the data is not that critically important. If it has some importance, there will be a paper trail. As another commenter said, they either have a process to audit the validity of data entry or they don't. Whether it was hand entered or automated is irrelevant.

Throughout this thread you've been arguing from extremes, invoking cases where such a thing could be disastrous, etc and using that as a general purpose argument. No one is saying there aren't occasions where IT should not interfere - I've acknowledged that there are cases where they should. There's nothing to indicate that the original commenters use case is one of those.

And this is what people in the thread are caring about: Someone who has no idea about the problem interfering with a perfectly fine methodology.

I could go on and address your other points in this and other comments, but I don't want to discuss this with someone who doesn't seem to understand the problem domain at all.


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.

There's no "prod outage" here. It was a data entry script.

What happens with that data, though? Is this a non production data entry job?

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.

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

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

It's a data entry script. If it fails they just do their job the old way until the guy fixes it. It's typing text into forms. Just make everyone do things the "old way" once a week so they still know how to do it if the script ever fails.

Okay, but after a week (or two or whatever), how do you rectify the issue you found? It's easy to say get those people back and have them start entering again. What about the customers whose information was inaccurate, the resources that were misallocated, etc? Do you think data entry is done for fun? At AWS we use massive metrics and piles of data to decide what's right; why would an oil company be different, just because their metrics are collated by hand from smaller oil wells into larger spreadsheets or whatever? "By Hand" doesn't mean "totally without value", that's completely wild. Does your super low opinion of data entry people cloud your vision of their value?

There's not been a response to my question of how you reconcile things after this script messes up for the first time; how does that happen? What's the DR plan? if you have real business and real clients working on this data, tell me what the plan is; it shouldn't be that hard.


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

Once again, if I wrote my own Python script they would not be involved, and my Python script is as error prone as using AHK.

Think of AHK as similar to a compiler + linker. By rejecting AHK because someone can write a program that could screw things up, you might as well just prevent people from writing scripts and compiling programs.

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

You've essentially argued that IT should oppose any automation that is not thoroughly tested. And how will they determine how well it is tested? Do they have those skills?

Where I work, IT is more concerned about security (viruses, theft, etc), licensing, and things that can break the machine. They don't prevent people from using APIs to mass edit databases as long as you do it to data you own or have permission from the owner. They don't own the data, so you're free to screw it up if you're careless. Ensuring my program is bug free and well tested is the job of my team/org/data owners, not IT.

You're merely pointing out that this IT person has been given more power than his skills warrant.


Okay but if you have an organization whose lead of IT isn't capable of verifying some automation - be it AHK or Python or VisualBasic or F# or haskell or whatever - then it's fine for them to say 'no'. You can go over their head, and that's also okay. Or ask them to bring in someone who's an expert in the technology you're using.

> You've essentially argued that IT should oppose any automation that is not thoroughly tested. And how will they determine how well it is tested? Do they have those skills?

In large scale, business critical applications? Yes. All everything should be thoroughly tested and/or canaried, with several levels of validation before production releases.

> You're merely pointing out that this IT person has been given more power than his skills warrant.

I think I'm pointing out that his job is to be a safeguard against rogue wanna-be programmers whose ability to destroy things far outstrips their ability to test for things (or even think about edge cases). If that's true, they've done a fantastic job.


Some good points. Some more context: this made a manual process semi manual. You still had to enter the data and the target programs still flew around (on screen) on the background. I think the risk profile was similar.

> 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?

Nothing of the sort :)

But... Let the adequate be the enemy of the less awful?


why even have programmers if they have to convince someone that doesn't understand what they're doing that it's been implemented correctly? the justification of an ignorant person not understanding it (assuming, i guess(?), that they are also incapable of learning it, apparently?) and thus not allowing a massively more efficient improvement to be put in place as somehow a job well done seems crazy to me. (at least in theory managers are supposed to provide something to the table). well, i guess to all the other programmers who, like me, leave any and all places like this. i acknowledge that not everyone is wired the same way, but it just seems blatantly obvious that the left hand wants "innovation" and the right hand... does stuff like this.

Everyone wants innovation, but no one wants responsibility. So anything can go as long as someone else signs off on it.

Exactly.

A lot of programmers, or programming enthusiasts, thumb their nose at IT staff who naturally push back on stuff like this. In their mind, to play devil's advocate, they're seeing IT as unnecessarily burdensome, and getting in the way of automation.

The IT staff are probably naturally welcoming to the general idea of automation. However, to elevate something up from an off the cuff script that's described as "depraved" to the level of an actual business tool that can be relied upon, is a HUGE time and money sink. Validation is a very complex problem as you have described. This is the difference between consumer and enterprise hardware. If business management isn't setting this as a priority for IT, and if IT is already overwhelmed with the "known" quantities of work, then it just isn't practical to officially adopt.

I see it like this: It takes 1 "effort point" for a data entry staffer to manually enter the information tediously. It takes 10 effort points for the same staffer to write the AHK script to automate it. (Good for the staffer, assuming there's no flaws, and their reward is a longer lunch break.) To truly validate an automation as a business tool would take something on the scale of 150 to 200 effort points and involve lots of conversation - assuming there even is a framework for new tool validation established that can be used. IT knew this and made the right call. If company management wants to adopt a new tool without research and validation, that can be reckless.


I don't think AHK or python or whatever is the issue here, it's automating the consumption of a ton of data without consulting the consumers or vendors of that data, or enacting correctness guarantees. It seems like you're hung up on AHK vs not-AHk and that's not something I care about. I've seen and been involved in a lot of naive automation of human processes just to see all of the edge cases destroy a business for weeks or more on end.

So actually he didn't want to be responsible for deploying more widely. I kept on using it. I was probably not meant to.

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 <b></b> and later <strong></strong> (yes, it was that long ago). I had some nifty ones with logic for adding <a>s (looking for @ and 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 - Like 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).

For #1 (just as an alternative) I've had good luck with this extension: https://addons.mozilla.org/en-US/firefox/addon/don-t-fuck-wi...

Thankfully I've never had to deal with #2


I have that extension, too!

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

If you mean "why do they prevent pasting?" -- because their talented and conscientious devs think password managers are insecure. I've tried emailing several webmasters about this but it's a waste of time.

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 :/

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


For a really stupid example, part of my job involves originating truck shipments. One carrier we use has a website that prevents pasting on their web form to generate a bill of lading. Because forcing me to type in an address is much less likely to cause errors than pasting in whatever address I had copied.

Funnily enough (in a sad way), 40% of the JS load on that page appears to be anti-pasting logic & supporting libraries. It appears to be developed in-house, since the scripts aren't obfuscated and a quick search of duckduckgo didn't match any open-source libraries that I could find. If they weren't reliably the cheapest carrier with the fewest issues I would raise a stink, but it's not worth it. That, and I just bypassed this 'feature' with a very similar AHK script, and their website has a very nice UI besides that issue.


It's an easy way to feel smart? I had to put up a fuss about this and cite NIST. My bank tried to do this, but it only works on the username field in chrome?

The irony of all this is that one time in the 00s, I signed up for a website and copied and pasted my email to the verify field and it was wrong!

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 !


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


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.


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


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


> I ended up being more interested in the programming than the game

I’ve been a swe for years, but this is how I felt about Pokémon go before they started blocking the apis people had developed. My only goal was to catch all 151 Pokémon. Because of where I live, I had a very hard time finding pokestops so I looked into and found the apis.

I was able to grind out lvls and catch Pokémon, spin stops, etc. I won’t go into all the things I did, but it sure was fun. I suppose I was harming the game because I wasn’t spending real money on in-game items, but besides that I don’t think I was harming any of the other players.

APIs got shut down, haven’t touched it since.


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


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.


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

> 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 :).


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!


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!

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

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.


And on Windows you can use WinCompose to get all the normal compose key sequences and more, plus you can add your own in with ~/.XCompose.

I love my Compose key. When I looked into purchasing a Surface Book (and switching to Windows) some four years ago based purely on its specs, the two critical factors were WSL and WinCompose—without either one of those two, I couldn’t have, wouldn’t have switched.

(I also use an AutoHotkey script for a few other things like remapping Win+F to maximise/restore, and disabling the horrifically slow Win+Tab which was too easily triggered by accident.)


For more, sxhkd is easy to configure and powerful: https://github.com/baskerville/sxhkd

or just use i3

I've bound my Caps Lock to Compose, it's really quite handy.

I wish there were a Unicode lookup utility app that would display a character's compose sequences if any, but none seem to be under development / accepting feature requests or patches.



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


AKH v2 has been "upcoming" for close to a decade now.

AutoHotkey started out as a fork of AutoIt by Chris Mallett, who stopped development around 2010 or so. Then Steve Gray (Lexikos) continued development under a fork called AHK_L, which later became AHK v1.1, and he's been the sole maintainer ever since. The GitHub repository is still fairly active, and I believe the v2 alpha is fairly stable, so I'm curious as to what changes still need to be made before it's done.


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.

Seems to me like we need a 1to2.ahk file

Linux users, see 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 .


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.

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


For much more limited uses, which still covers a lot of what I care about, there's xdotool. A major difference is that xdotool just creates input events, but doesn't hook triggers; I just use my window manager for that.

Yup. wmctrl too; sometimes one is more friendly for the specific thing you need done, sometimes it's the other way.

Passersby, warning, both are Xorg-only. For wayland, see https://github.com/ReimuNotMoe/ydotool but the naming is confusing, as it doesn't work exactly at the same level: ydotool is about keystrokes, not window management.


What about espanso? Cross platform including Linux

https://espanso.org/


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.


You visited HN 1,240 times in the last month.

We recommend that you just park it in a corner of your screen and turn on an auto-reload tool.


I might be misremembering, but I think there was a package for Emacs that would track the most frequently used M-x commands, so that you could later look at the list and see which ones are worth binding to a key. I can't for the love of me find it now.

theres a function somebody wrote (acc.ahk) that can detect elements and text in a lot of windows programs. it can click things like the "add to library" button in spotify even when the window is minimised

there is the COM object that detect the same sort of things but in web browsers, but it only works in IE only. for firefox or chrome you would need to use selenium.

maybe these things can detect certain things being clicked as well? i dont know


It would be the best privacy invading tool you could come up with :)

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

I've dreamed of making this.

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.


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!

On macOS a similar tool is Keyboard Maestro (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...


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.

I'm not quite at 1400 (yet!) but I truly depend on it... a fresh install of macOS feels broken without it. Even better when combined with Karabiner, as you too suggest.

PS: great site!


It's a fantastic tool. I've been using it for years and I love it. Also works great with the Elgato StreamDeck.

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

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


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

I saw this video last week and it reminded me of an AHK tool I wrote years ago to work around some ERP flaws, can't really say more.....

The video also reminded me to let some of the young guns in my team into the AHK secret


The American version of "bodge" is the similar "kludge". And yes, AHK is a kludge that makes kludges. Kludges are wonderful.

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://www.jklmouse.com/


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!


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


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.


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!

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.


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.



Thanks!

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

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 :)

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)

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


well ive never made a GUI in anything other than autohotkey so i wouldnt know what it is like in other languages, but it is indeed fast. ive been using autohotkey for maybe 4 years now so when i want to make a new GUI i usually just copy bits from previous GUIs that i have made.

otherwise there is AutoGUI that makes it really fast since you just have to drag and drop the elements you want

> the resulting script can be bundled into an .exe file

thats another thing that i dont see mentioned enough about autohotkey. being able to make scripts for other people and giving them just one file to run is so underrated!


Very much this. Years ago I wrote an AHK script to save the contents of the (image) clipboard to a file, and insert an Org mode link into my Emacs buffer. The GUI was simple: Just give me a dialog box so I can specify where to store the image. Once I do that, it provides the full path to my Emacs function.

I'm not an AHK expert. Very much a beginner. This was trivial.


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 :)


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


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.

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.


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

OS X: Use triggers in QuickSilver: https://qsapp.com/

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


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 [1]: https://www.youtube.com/watch?v=lIFE7h3m40U


“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?


Dragon works much better than Siri for me.

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.


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.

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


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.


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

Nope. The cert I get expires May 20, 2021

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

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.


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.

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

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.

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

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.


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.

For this kind of automation, I use pyautogui, but recently I made a kind of front end for that https://github.com/rmpr/atbswp

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.

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.

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.

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!


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


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.


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

My goodness, the formatting.

  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

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/

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


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

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.


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 :-)


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


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.


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


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


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.

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


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!


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.


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.

No, he was promoted and fated. Those scripts required maintenance!

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?

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.


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.


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.

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.

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

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.

I don't use much of AHK, but I love it.

https://www.2uo.de/my-autohotkey-script/


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

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.

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.

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

> It's also great for macros in video games.

I found it tedious to write long macros manually, so I wrote my own tool https://github.com/rmpr/atbswp, for fine grain control AHK is very good, but for quick and dirty things I rely on atbswp.


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.

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

theres actually a fair few things that do work with wine. any of the GUI stuff (although it looks a bit ugly), writing and reading to a file. menus. lots of other bits that i cant remember now.

but it only works with other programs that are running in wine so theres not a whole lot you can do with it at the same time. ive mostly been using it to process strings and that sort of thing.

ive been thinking i should try and make a list somewhere of what is working and what isnt. it would make it easier to test things every time there is a new version of wine released

i made a script for autokey that will run the selected file in wine when you press alt + r. if you download the portable version of autohotkey and add the path to it then you can use the same hotkey to run the a script

https://gist.github.com/davebrny/9850223119c4ee55485dfae1fcb...


I think it works on Linus as well, doesn't it?

There seems to be a Linux version called Autokey, indeed.

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 :(

Does anyone know if using AHK increases input latency at all?

In some programs, yes. I've found it works horribly in Notepad++.

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/, 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, free) can be used in some cases. For examples, compare three of the solutions on 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/, 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/, 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/, 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/, 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.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: