Hacker News new | past | comments | ask | show | jobs | submit login
AutoHotKey V2 (Breaking Upgrade) (autohotkey.com)
218 points by numeromancer on Jan 4, 2023 | hide | past | favorite | 120 comments



Somewhat timely. AHK is one of those utilities I absolutely cannot go without. I've been running it on all my Windows machines for 15 years now.

Just a few days ago I was complaining¹ about how Excel handles formula input. After some back and forth on my yak-shaving attempt, I realized I could shave it myself with AHK.

With this little bit of code, my [Enter] and [Tab] keys work the way I want them to in Excel. This is still version 1.1, not 2.0:

    ; Try to "fix" Excel formula bar
    ; ==============================
    IsExcelFormulaBox() 
    {
        ControlGetFocus, F, A
        return (F="EXCEL<1")
    }

    #if IsExcelFormulaBox()
    Tab::
        ; Look for the little function list that pops up when suggestions are available.
        ControlGet, X, Visible,, SysListView321, ahk_class __XLACOOUTER
        ; If list is visible, then pass [Tab] through. If not, insert 4 spaces
        if (X) {
            Send {Tab}
        } else {
            Send {Space}{Space}{Space}{Space}
        }
        return

    ; Swap [Enter] and [Alt]+[Enter]
    $!Enter::Send {Enter}
    $Enter::Send !{Enter}

    #if
[1] https://news.ycombinator.com/item?id=34176791


...holy crap. You just blew my mind.

I have HUNDREDS of little AHK hotkeys. I use some of them dozens of times a day. I've been wanting some way to directly target Excel like this for literal years.

Thank you!!!


:) I’m kinda both proud and ashamed. I’ve also hated the ergonomics of the formula bar for years, but never tried to do anything about it.

I’ll bet I find more weird corner cases with this hot key. My first attempt didn’t handle the autocomplete, and that was a big letdown until I found the workaround. I’m sure I’ll run into something else as well.


In return, as a token of my gratitude, I give you a script that allows horizontal scrolling in Excel with Shift + Mousewheel (bafflingly not a default in Excel, even though that's becoming standard almost everywhere else):

  ; Excel horizontal scroll with Shift + Mousewheel 
  #IfWinActive, ahk_exe EXCEL.EXE 
    +WheelUp:: 
      SetScrollLockState, On 
      SendInput {Left} 
      SetScrollLockState, Off 
    Return 
    +WheelDown:: 
      SetScrollLockState, On 
      SendInput {Right} 
      SetScrollLockState, Off 
    Return 
  #if


I just added it. Yes, thank you, this works great.


Sorry I'm on my phone right now so can't test this out so what does this do exactly?

I just have my formula bar set at 3 lines and F2 edits in the formula box always. I find that works well for me.

What frustrations do you have with the default setup?


I like to do multi-line formulas and use indentation as well.

To insert a newline you have to press [Alt]+[Enter]. To indent you can’t use [Tab], so you have to manually space it out.

My script swaps the [Enter] key behavior so regular pressing inserts the newline and Alt+Enter commits the formula. It also converts a Tab press to 4 spaces (rather than focusing away from the bar)


Also, are you aware of the new Advanced Formula Environment?

https://youtu.be/yIAl1XbuVzU


I wasn’t until last week. Pony_Sheared linked me to it

https://news.ycombinator.com/item?id=34178234

I downloaded it but haven’t had a chance to tinker.


My favourite script was from when I was playing Diablo 3 heavily (around 2015), but for a while I had been pressing my mouse hand too hard into my mouse pad which were causing some RSI issues.

I found a +-300 line script which allowed me to play with a controller (made by zarzare), I modified it for the different classes and it worked ridiculously well. It used basic trig to create a circle around the player's position and cast abilities in that direction. You could specify a short/long range so abilities could be cast either short or far, depending on the range of the ability.


I'm still reading through the changes ( https://www.autohotkey.com/docs/v2/v2-changes.htm ), but I like what I'm seeing so far. So many (many many) quirks and special cases are just gone now, I suspect users will find it much faster to learn and easier to avoid getting stuck on odd burrs on every corner.

I learned programming with AHK back before data structures like maps and arrays even existed (!), and I'm happy to see it's still getting better. I still use a few utilities that I built on a daily basis.


As someone who recently dove back into AHK, I must say v2 has been fantastic!

So many great quality of life improvements and overall the documentation is top notch. I cobbled together a launcher app and modal-hotkey system from scratch in a couple of afternoons of enjoyable work.

If you're looking to try stuff out, having an autoreload function is a very nice addition to your script while developing.

A very pragmatic and productive experience.


Honestly I love the AHK documentation.

Some of the scripts I use daily are in Python, and some are in AHK. The AHK documentation is much easier to follow than the Python documentation IMO.


I came here to comment the exact same thing. AHK documentation is by far the easiest to navigate and u derstand of any language I've learned to date.


Is the modal hotkey system public code?


Uhh it’s a bit hacky at the moment but I can clean it up a but and release what I got.

Really it isn’t much more than an abuse of the Hotkey function and (effectively) function pointers.

I’ll put it up this evening though if people want to peep at it.

[Edit] In case people miss the other reply it's here: https://github.com/url00/ModalAHK


Here's a modal remap I've been using for the past few years. It's a bit rough around the edges, but should work reasonably well: https://github.com/MatejKafka/KeyboardRemap


Here's what I got. It's still pretty thrown together but hopefully it's helpful for ideas at least: https://github.com/url00/ModalAHK


I've already ported my AHK script to v2, and it was mostly painless. It helps to use VS Code with the extension so that it can highlight what syntax would fail (mostly). Most of it was trivial like adding surrounding quote around `Send` function's param, as well as prepending `#HotIf` in front of WinActive(). As an added benefit, my dual function key is more reliable, ie sending capslock/control as escape or ctrl. (See last entry in https://www.autohotkey.com/boards/viewtopic.php?t=92738)


This is a bit of a PITA for me as most people use AHK to handle shortcuts for komorebi[1], which led to me generating an AHK library[2] to help people write their configs. Turns out every single line of that generated library (not to mention the entire sample config for newcomers) is now invalid syntax in v2.

I'm taking a month off from development while I'm traveling, maybe I'll feel less salty about this when I get back.

The biggest issue right now is that the Run and RunWait commands require strings for the commands to be executed, and AHK v2 has absolutely garbage support for string interpolation.

Honestly I'm not sure if I'll continue supporting AHK or just develop my own sxhkd (swhkd?) and recommend that for users going forward.

[1]: https://github.com/LGUG2Z/komorebi

[2]: https://github.com/LGUG2Z/komorebi/blob/master/komorebic.lib...


I have been coding with v1 for about 15yrs and switched to v2 in a heartbeat.

But I would definitely not recommend converting v1 scripts to v2 if is not absolutely necessary.

You can have both installed and work great with the new launcher that auto selects version based on the #Requires directive.

I would definitely not convert v1 scripts that are longer than 2k lines.

What I have found is that re-writing stuff for v2 is WAY easier than converting.

You might also try the v1 -> v2 converter by dimitri. It is not perfect but does 90% of the work for ya.


As far as string interpolation goes, what's wrong with the format() function? It was already in v1, and hasn't gone anywhere in v2.

https://www.autohotkey.com/docs/v1/lib/Format.htm

https://www.autohotkey.com/docs/v2/lib/Format.htm


Tried this but it didn't work as the first arg to Run or RunWait :/


Works fine for me?

v1

    RunWait, % format("{}.exe", "notepad")
v2

    RunWait(format("{}.exe", "notepad"))


Appreciate this, I will take another stab now that I have a working example!


Can you just specify AHK1 for users for the time being? Is there an equivalent of a shebang, differentiator, or something in AHK scripts that'd allow a simultaneous v1 and v2 install? When Python went from 2.x to 3.0, there wasn't some expectation that all adoption of breaking changes happen immediately - one hopes similar provisions have been made here.


we have the #Requires directive

e.g.: #Requires Autohotkey v1.1.36+ 32-Bit

When you install v2 it has a launcher that can be configured and runs scripts with the correct interpreter based on that directive.

If that directive is not in the script it would try to determine the version based on syntax. And if it couldnt determine it, it would ask you what to do.

I have both versions installed and have had no issues as of yet.


Very useful program.

We had an old Tadiran phone system, and it was losing time. Randomly through the day it would lose anywhere from five minutes to two hours.

Of course, the system wasn't under maintenance any longer, and the phone place wanted $4,000 for a new motherboard (the crystal was bad so the clock was wrong, or so they said). Considering everything else worked fine, we just manually set the clock here and there.

And then I found AHK, and wrote a quick script that logged into the phone software, entered the correct time, and saved it to the system. Set that to run every hour and ever heard anyone complain about it again.


The changes doc would be 10x more usef if it included more examples of the changes. https://www.autohotkey.com/docs/v2/v2-changes.htm

I do wish programmers had more options in general for this kind of thing. I ran into https://github.com/autopilot-rs/autopilot-rs lately but it is extremely simple. On Windows there s UI Automation, which can help script many conventional apps. https://learn.microsoft.com/en-us/dotnet/framework/ui-automa...


I struggle to get things done on any PC until I install my personal AHK script which remaps certain keyboard and mouse functions in ways which dramatically accelerate my productivity.


Same! A couple of my super-short must-haves are:

  ; Map CapsLock key to Control
  CapsLock::Ctrl

  ; Ctrl + Alt + Arrow key jumps to beginning/end of line/document; 
  ; Add Shift to select as well
  ^!Left::SendInput, {Home} 
  ^!Up::SendInput, ^{Home} 
  ^!+Left::SendInput, +{Home} 
  ^!+Up::SendInput, ^+{Home} 
  ^!Right::SendInput, {End} 
  ^!Down::SendInput, ^{End} 
  ^!+Down::SendInput, ^+{End} 
  ^!+Right::SendInput, +{End}
On any PC without these running I feel hobbled. It's like my shoelaces are tied together or something.


The bit about the anti-malware is sad. Does anyone remember a true positive from their AV? I can recall countless incidents caused by false positives, but can’t remember a single true positive.

The latest was Crowdstrike Falcon (AI POWERED!!1) flagging signtool.exe as malware. The one from the Windows SDK. By Microsoft. Signed with Microsoft keys.


> Does anyone remember a true positive from their AV?

Yes. I don't remember the details but there was one time where it prevented me from executing some download that was malicious. This was more than a decade ago.

On another occasion (around the same time) it failed to prevent malware from executing. I never found out what the method of infection was, but after changing back the wallpaper and removing it from startup programs, I suffered no further ill effects... fifteen year old me was not very thorough but seems to have worked anyway.

And then there are the numerous annoyance occasions where it false-positived on legitimate software like Nirsoft, Cain&Abel, Netcat, Nmap, etc. Not to mention corporate proxies blocking my personal link shortener but being fine with bitly. Security theatre, those are.

To be fair, AV also prevents executing standard metasploit things and attackers have to be a bit more creative which gets tedious and so it can be an indicator of compromise to have this pop an alert even if the attacker succeeds a few minutes later.


Security is hard. It is only when you have to fight never ending scenarios from multiple users that you understand how limited a product that helps you is.

Crowdstrike helped us a few times to contain serious issues, and made me difficult for people as well because it blocked their "suspicious" behaviour.

The bad guys only need to succeed once.


The latest was Crowdstrike Falcon (AI POWERED!!1) flagging signtool.exe as malware.

For more than 99% of their install base its presence on a system may be a decent indicator of compromise. Maybe not worth flagging by itself but worth investigating anything that bundled it.


Is it weird that I like Windows only because of AHK?


Whenever I mention why Windows is my OS of choice, one of the very first reasons I list is AHK. I have hundreds of little macros that save me gobs of typing. It works beautifully almost anywhere (Although, NP++ hates it... I wonder if V2 fixes that?)

It'll be a while before I give it a try, because it sounds like I'll have to convert a bunch of stuff- but I'm definitely going to give it a try. I'm just overjoyed that AHK is in active development still! Been using it for well over a decade.

My Favorite Use of AHK

2014. My grandfather was in his mid-80's. He lost dexterity in his hands, and was having a very difficult time because he was clicking both left and right mouse buttons at the same time.

AHK to the rescue! I re-mapped right mouse button to nothing, effectively disabling it. Then, I mapped NumPad+ to the right mouse button. If he needed to right click, he just pointed, pressed NumPad+. Otherwise, he could click both buttons all day long and the computer operated just fine.

He got a few more months use out of that before he passed away, and it remains the most meaningful computer fix of my entire career. I miss that man. A lot.


A little, but I did drop by this thread to say that it's one of the absolute "killer apps" for windows. It's a very VERY complete swiss army knife of automation and makes it trivial to build little utilities that interface with the OS. I use it all the time.

It's been a while so perhaps the situation w/ linux and OSX has improved, but IIRC linux was very fragmented/finnicky and OSX is absurdly overzealous on permissions so you can never get anything useful done.

I'm constantly frustrated by the enormous gulf between what my computer COULD do vs what it actually CAN do because of how much stupid wall building everyone does. AHK is one of the few things that meaningfully bridges that gap. There are so many things that are infinitely frustrating because you have to click through like 10 menus instead of issuing a simple API command, and with AHK you can get some of that back.

We live in a world where 9 times out of 10 I won't open Premiere or whatever, because it's so much faster to just use ffmpeg. I want a world where Premiere still has all it's ui shit, but also has a decent scripting interface. It's one of the reasons I'm so bullish on Blender in the 3DCG space. The scriptability/extensibility is so far ahead of everything except Houdini.


Nope, not weird. I feel exactly the same way.


I like AHK very much but its scripting language is difficult to use of you do not use it often.

The most complicated pay for me are braces and delimiters: I never know when to use a brace, when to use style #-delimiters (#HotIf for instance), when a mineral is enough, etc.

It would be much better if there was a decision to be homogenous and always require braces, or newlines or whatever - but always the same thing.


I personally use AutoIt a ton as a super fast way to quickly prototype GUIs. It's basically a really simple entrypoint for WinAPI.

Shameless plug: my script for emulating a trackball with your keyboard [0], and my tray app for quickly tweaking your cursor speed (usually for when I'm drawing something)[1]

There are also some really useful utility apps like WhyNotWin11[2] that's made entirely using AutoIt

  [0] https://github.com/EsportToys/TPMouse
  [1] https://github.com/EsportToys/MouseTray
  [2] https://github.com/rcmaehl/WhyNotWin11


The problem with AutoIt is it's openly hostile community.

What community it does have is extremely and openly hostile towards newbies and non-programmers. To the point where browsing their forums has become a huge turn-off, and definitely has rejected folks trying to learn programming and/or AutoIt.

Even experienced programmers sometimes ask "dumb" questions... and the hostility they're met with is unacceptable.


Oh, interesting, I wasn’t aware of how the community were, since their documentation is quite thorough and self-contained that I’ve never had the need to check their forums (on top of the language being quite straightforward). I learned entirely from the inline samples provided in every page of their documentation.


I have a mixed experience. Sometimes I got an insulting answer, and sometimes a throughout one.

My personal baseline for a toxic community is the Golang one on Stack Overflow. So far the AHK form is better.


AHK is great from what I've seen. It's AutoIt that's the problem. AHK was originally a fork of the FOSS version of AutoIt, before AutoIt went closed and proprietary.

A lot of the toxicity on the AutoIt forum seems to come from the grossly overinflated egos of few core participants (some of which appear to be employees in some capacity). Reading through the forum, you can easily get the impression these people believe AutoIt is better than sliced bread or something... and anyone needing to ask a question is simply dumb.

It's rotten to the core. People should use AHK whenever possible.


I dunno, I find AHK's syntax really hard to wrap my head around, whereas AutoIt is simplistic enough that I never had to even bother with the forums in the first place, the built-in helpfile basically has everything I needed.


Objectively, the syntax for both are horrible (based on BASIC I believe, but still). Magic numbers, hex numbers, huge number of function parameters, obfuscated parameter/variable names, etc. It all leads to barely readable spaghetti code even in the most well-written UDF examples. And... good luck trying to get anything but the blessed-but-insufficient-for-serious-work IDE to work for you.

Help files are decent... but if you need help with a concept/idea/implementation - you are much better served to seek that help anywhere except from AutoIt or their forums. Which is sad.


I love AutoHotKey but why do I have to learn a new language to use it? Why can't it use an established language like js or python?


Likely surface area and dependencies. Nothing is stopping you from using Python with some of the GUI automation packages. Sadly I'm not aware of any that are cross platform, then again neither is AHK or Auto it.


It's gone longer without a breaking change than Python, for one...


Let me start by saying that I appreciate the humour here :) However, in actuality...

Python is from 1991. Python 2 (from 2000) was not a breaking change if I'm skimming the "what's new in python 2.0" correctly. Python 2 was supported until 2020 (29 years).

Autohotkey from 2003 (19 years old now).

Unless AHKv1 is still maintained, Python wins by a decade.


Ahh, I was supposing if AHK had been written in Python, starting in 2003 because that's when AHK started, it would've experienced a breaking change in either 2008 or 2020, when Python 3 came out or when Python 2 ended support.

Either way, yes it was just a cheap attempt at a joke, thank you for seeing it as such! Python pedantry isn't my strong suit, obviously.


There is a nice python wrapper[1], perhaps that could work for your uses?

[1]: https://github.com/spyoungtech/ahk


Because AHK is about 20 years old. If it was created today it probably would.


As everyone says AHK is phenomenal but the scripting language is pretty warty. I wonder if they considered using Lua or something instead of improving their custom language?


I think the language is more of a feature than a detriment: much like Excel, it’s able to get non-programmers to do programming without realizing it. Both tools have a low barrier to entry and a relatively gradual learning curve.

All you have to do set up an AHK script is open up notepad, type a hotkey symbol, then some basic commands like “Click <X>, <Y>” or “Send <keystrokes>”, save the file, and double click to run. Doesn’t get much simpler. Loops and routines can be learned over time as needed, and aren’t necessary to meet most people’s use cases.


I think this has more to do with scripting nature of the language than its syntax itself - at least I always found the best/easiest environments to use in practice to be the ones that:

1) executed in a clear, top-down fashion, allowing to write code top-level, without wrapping it in functions and calling from an explicit entry point like main();

2) interfaced directly with the useful APIs, vs. having to manage libraries and namespaces;

3) interpreted directly from the source file, as opposed to having first run a compiler or other explicit, artifact-producing step;

Basically, languages that would let me just write minimum amount of code to solve, through trial and error and experimentation, my simple problems.

I believe this is where some Lisp language would shine, if not for the fact that you have to press SHIFT to enter parentheses... I suspect this is a large reason people ended up preferring scripting languages with punctuation that can mostly be entered without modifier keys.


I suspect it's similar to why we don't use Lua, Python, or whatever language is considered easy and quick to learn and write as a shell language. There are specialized cases where it's much, much faster to write commands in a custom language (even if it has to be a "proper" (e.g., Turing complete) language and not just some tags like markdown). From my limited use of AHKv1 a decade ago, I would suspect that AHK is such a case. You can get a long way with operator overloading, but having seen students who had decent C++ knowledge use CPLEX, I'm not sure it makes things any less confusing.


I agree AHK is warty... but Lua?


What’s the benefit of trading one awful language for another? Why bother?


As someone who has been using Macs since 2006 and recently moved to Windows, I cannot recommend AHK enough.


I only have a single AHK script (I don't use windows much) and it specifically maps WinKey + Q to close a window and WinKey + H to hide a window. Windows is basically unusable for me without this convenience script!


For me it was the CMD+` for cycling between windows of the same Application, can't live without it.

Do mean "hide a window" just the CMD+H in macOS? How did you do it?


Do you have an example on how to do CMD (CTRL) + ` on Windows?



Would you mind sharing this script?


It's one of the few things I miss from Windows as a Linux user. Some of it can be done using xdotool and other utilities, but nothing works the way AHK does.


Have you tried AHK for Linux?

Discussion and link at https://news.ycombinator.com/item?id=32654023


Good to know! Posted four months ago, "first functional implementation", nope that wasn't around yet >10 years ago when I switched and missed AHK.


Which is kind of astounding for an OS that is supposedly about flexibility and customization. Something like AHK should be built in to every personal computer OS, but it isn't for some reason.


You can run AHK on Linux with Wine.


> > Nested Functions

> One function may be defined inside another. A nested function may automatically "capture" non-static local variables from the enclosing function (under the right conditions), allowing them to be used after the enclosing function returns.

That sounds like a closure. I expected “nested” to mean that the function is defined inside another function but doesn’t capture anything, like what you can do in Rust. (It’s IMO a “why not?” feature—why don’t more languages allow it? It’s certainly useful for helper functions which are only consumed by one other function.)


Well, C++ has lambdas with explicit capture list. A captureless lambda is basically a function (it even converts to a function pointer), otherwise it's a closure.


Well, what? My objection is calling a closure for “nested function”, a term I’ve never seen for such a thing.


It's a very natural and obvious term (far more natural than "closure" IMO). The wikipedia page has citations going back at least 20 years.


You win.


I've seen nested function, whether or not it is also a closure, for ever; a closure is a function with an associated environment; a nested function is a function defined within another function.


C# has "local functions" [1], and i feel like "nested function" is an equally good name for the concept

[1] https://learn.microsoft.com/en-us/dotnet/csharp/programming-...


Eh, closure is just anested function. Just like a function can have access to global/static vars, a closure can also have access to vars in its parent scope. They are like global vars to it


Would a tool like Auto hotkey if it were implemented on Linux work with Wayland?


Some parts will work. Some parts won't.

AHK lets you run arbitrary code in response to global hotkeys. There is no wayland protocol for applications to register global hotkeys for themselves. Compositors can choose to provide their own hotkey configurations, and what you can do in response to those hotkeys being pressed depends on the compositor. For example in Sway you can register hotkeys to run arbitrary executables. Alternatively, XDP apparently has a portal API for applications to register global hotkeys, but of course it's up to the individual compositors' portal implementations if they implement the API. For example xdpw, used for all wlroots-based compositors like sway, does not.

AHK lets you read and set the mouse position. There is currently no wayland protocol, stable or unstable, for programs to read or set the position of a pointer (if the pointer is not over the program's surface).

AHK lets you introspect arbitrary windows to read the text of a focused textbox, etc. There is currently no protocol, stable or unstable, for programs to implicitly grab the content of surfaces under the pointer, let alone read text of textboxes. At best you can use the XDP Screencast protocol but that only gives you images (AHK integrates with the standard Windows graphics UI API so it can detect textboxes etc), and even then it might pop up a permissions dialog for the user to approve like you would expect for a screencasting program.

AHK lets you insert arbitrary keyboard sequences into the focused window. There is no Wayland protocol for this, but you can just use a new input device through the uinput kernel driver instead of anything Wayland-specific. (ydotool does this.)

AHK lets you read and write to the clipboard. There is an (unstable) wayland protocol for clipboard managers that can be used for this.


Thanks for the helpful summary. Capturing key presses could also work by talking to the kernel directly.

> There is currently no protocol, stable or unstable, for programs to implicitly grab the content of surfaces under the pointer, let alone read text of textboxes.

Yes there is, AtSpi, the accessibility protocol. But a normal window-independent `Click, X, Y` would indeed be quite important to have...

I'm wondering if there is a way to somehow get active window position, move windows around etc. using root privileges, without relying on a custom compositor extension. Could not find anything.


>Yes there is, AtSpi, the accessibility protocol.

Right, "protocol" in that sentence meant "Wayland protocol". I'd forgotten about AT-SPI, and it's true that it solves that problem, though it seems that it also includes API for synthesizing input which would require the compositor to implement something.

>I'm wondering if there is a way to somehow get active window position, move windows around etc. using root privileges

Root doesn't matter, because the compositor isn't running as root either. ie being root won't give you any more privileges over it that just being the same user doesn't.

Things like "active window position", "move windows around", and even the entire concept of "windows" are internal to the compositor. Wayland only talks about surfaces; what the compositor does with those surfaces is up to the compositor. It might display them as windows, or as sides of a 3-D rotating cube, or print them through a printer. So you're not going to get that information from anywhere other than the compositor.


The solution seems obvious: build something like AHK into the compositor itself, since that's where all this is happening anyway. Do any compositors do that?


Wow! So this really is a blocking issue for accessibility and automation framework.


AHK_X11 is AutoHotkey for Linux and it does not yet support Wayland, but it's definitely possible https://github.com/phil294/AHK_X11/issues/2 (see also: ydotool)


There are a lot of tools available which allow to generate/automate mouse and keyboard events within Wayland. Here's an example (I use another ydotool and another one, on another machine; don't even remember what it is called) [1]. It describes how they require a udev rule and use /dev/uinput

Examples I use: 3 finger swipe to left/right switches desktop in Sway, rebinding caps to esc.

[1] https://crates.io/crates/tfc




Wow! This is exciting! While in my dreams I would still prefer a Rust alternative, sadly there isn't one.

I have a ~5000loc script that I've been planning to rewrite, but there was never much reason except stability. But I guess now is the right time!

I am still looking for some modern AI OCR for AHK, because the solutions that I've found this far hasn't really worked well.

I must say, working with AHK is always fun, even though not implementing press ESC to exit the script can be quite fun.


Here is a question for everyone: What would it takes for ChatGPT to provide support for the AutoHotKey V2 syntax? Is the manual sufficient? Would it also need a library of sample codes? Would it require StackOverflow posts?


I first used AHK for macros in games. The scripts can even read pixels on the screen, play sounds or beep, execute programs, send mouse click/events. And of course send keyboard keys.

It is great for automating things.


A lot off people dont understand which version to use. this video sheds some light on which is best for people https://www.youtube.com/watch?v=aMCP4hyzXwg


AHK is what keeps me on Windows


I was a Windows guy: And when I moved to Linux I made some notes that I might have problems because of:

AutoCAD - true

Photoshop - true

SketchUp - true

AHK - not so much.

Autokey does what I need. But I still have great time for AHK - which is why I looked at this thread. Yeah, there's GIMP and Blender and SU online but these applications were really ace on Windows. I found a way to live without them all.


> I found a way to live without them all.

I'm not willing to sacrifice my productivity for some ideological purity.

It would take weeks to create a fraction of what AHK already does for me with scripts I have improved every year.

I tried to explain in another thread some of the remappings I have: like how Caps often ends us remapped to Esc (when alone) or Control (in conjunction with another key: act as a modifier) on MacOS, my 2 shifts and 2 alt do their normal modifier function (when used in conjunction with another key) but when used by themselves act as PageUp/PageDown Home/End

Going up 2 pages up in the browser? The left shift pressed twice (Shift Shift) gives me 2 PageUp. Top of the page? Alt gives me Home. Bottom? The other Alt gives me End. Select from the point of edition to the beginning? Shift+Alt does Shift + Home. It's not the homerow, but it's 2 keys easy to reach, and never missing (unlike the actual PageUp which is often Fn + something - no I don't want to turn that into 3 or 4 keys).

Yes, doing Cap s=> Esc or Control is possible on Linux, but the rest will be complicated.

And it's just one of the many things AHK does for me! Here's another example: a partial screenshot into a base64 encoded PNG is just 2 keys away.

It might be possible to do all that on Linux, but last time I tried to get something a fraction as good as mintty (with ligatures, italic, sixels...) the best I could get was a pimped xterm.

For what I do, the tooling is just much better on Windows - and yes, you may not believe it, but even for tty/console things.


> Going up 2 pages up in the browser? The left shift pressed twice (Shift Shift) gives me 2 PageUp.

Is this on a device with a tiny keyboard, or is it really something you do so often you want it on the main area instead of pressing PageUp twice?


This AHK hotkey sounds like a thing I'd do (and I use AHK as well):

/Sure/ I can scroll with mouse or page-up, but that needs my right hand. And I eat at my computer while reading sometimes...

So I put a scrollball on the left side of my keyboard. (though spacebar and shift+spacebar generally work too)

https://hackaday.io/project/203-keyboard-with-apple-mouse-sc...


On MacOS there's a few options: Keyboard Maestro, BetterTouchTool, Karabiner, Hammerspoon.

Most of them aren't free and I haven't found any of them to be better than AHK, but they do the job well enough that it's certainly not a reason to look back fondly to Windows despite my lack of enthusiasm for MacOS.


Its very easy to add a feature with Karabiner Elements as it can download scripts from a repo. Hammerspoon too, has a lot of snippets and scripts available (I haven't used BetterTouchTool as I avoided touchbar Macs). That's one of the strong points with AHK. I look up a syntax or example code and boom (and I am a lousy programmer so if it works for me, that says something).

But I got AHK running in Wine on Linux, and on another Linux machine with Wayland I got simple rebinds and simple scripts working with keyboard and mouse (which I could extend with say Python scripts from AutoKey?). Its more difficult on Linux, but its possible.


Keyboard Maestro for macOS is great although it's not free like AHK.


AHK is the only reason I miss Windows (being on Mac presently). I had dozens of system-wide text expansions and optimizations. Also, a num lock toggle every 9 minutes to keep my screen awake.

Text Shortcuts on Mac is limited and unreliable, and I haven’t found a good 3rd party replacement yet.


I wonder if it will work with the IDE that someone had written in AHK V1. I can't remember what the website was, but it was a rather impressive IDE. All in one 10,000 lines file of course. Does AHK even support support packaging multiple files together?


I am a windows user, working more than 5 years as a backend developer and didn't use AHK ever. What do you use it for? I mean, can you give some examples of your scripts or tasks you perform with it?


How long was v2 in beta? I remember writing a bunch of beta v2 scripts years ago


While the change is probably quite needed, I hope it won't turn the years and years of help from forums irrelevant.


I was never able to make AHK to have 3 keys combinations, like Win+K+O to do something. Has anyone succeeded? Is it now possible on V2?


if the breaking upgrade thing is such a problem I guess it should be possible to run both versions side by side, although might require some registry tweaks?


It's trivial to run both side by side. You can easily switch between interpreters.


I expected, just a few people seem especially upset about the upgrade breaking their scripts.


AHK has the distinction of being an absolutely indispensible tool and a horrendously terribly designed language. It's probably the worst-designed programming language I've ever seen. Whenever I'm frustarted with how slow and conservative Python development is, I remind myself that this is the main thing keeping us from reaching the same state as AHK.

I hope that this upgrade will fix some of these problems. I'll probably take a few years before I upgrade my AHK scripts.


> It's probably the worst-designed programming language I've ever seen.

I always wonder in these discussions why bourne shell/bash gets a pass. Many people know it, but are somehow blind to how terrible it is.


Probably not a lot of overlap between people who use AHK regularly and people who know shell well enough to be confident that it's a bad language and not just something they aren't used to.


This is true, but I feel amazing whenever I get something working and when I execute a shortcut.


I'm surprised no one has mentioned this; AHK broke compatibility with this upgrade. I tried upgrading autohotkey and it braked my scripts. It seems to have an auto-regress feature, which is nice. If someone knows where there is a comprehensive this-for-that upgrade guide, that would be nice; I didn't see such a thing on the site.


Well, it is the second sentence on the page:

> AutoHotkey v2 aims to improve the usability and convenience of the language and command set by sacrificing backward compatibility. As such, scripts written for v1 generally will not work without changes on v2



That's in the title. Was the title changed?


you can have v2 and v1 installed and running at the same time. I dont see any issues with the newest version :)


I don't now. I had updated AHK through `scoop`, and saw the pop-up about downloading a previous version which I didn't understand at the time. Then proceeded to find that my scripts were broken, went to the AHK site and saw the V2 info. I played with updating my script for a little, then postponed it and let AHK regress for now. I was then surprised when I searched HN and found no post about the update, so decided that I would let everyone here know what was afoot.




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

Search: