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.<p>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.<p>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:<p><pre><code> ; 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
</code></pre>
[1] <a href="https://news.ycombinator.com/item?id=34176791" rel="nofollow">https://news.ycombinator.com/item?id=34176791</a>
I'm still reading through the changes ( <a href="https://www.autohotkey.com/docs/v2/v2-changes.htm" rel="nofollow">https://www.autohotkey.com/docs/v2/v2-changes.htm</a> ), but I like what I'm seeing so far. So many (many <i>many</i>) 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.<p>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!<p>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.<p>If you're looking to try stuff out, having an autoreload function is a very nice addition to your script while developing.<p>A very pragmatic and productive experience.
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 <a href="https://www.autohotkey.com/boards/viewtopic.php?t=92738" rel="nofollow">https://www.autohotkey.com/boards/viewtopic.php?t=92738</a>)
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.<p>I'm taking a month off from development while I'm traveling, maybe I'll feel less salty about this when I get back.<p>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.<p>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.<p>[1]: <a href="https://github.com/LGUG2Z/komorebi">https://github.com/LGUG2Z/komorebi</a><p>[2]: <a href="https://github.com/LGUG2Z/komorebi/blob/master/komorebic.lib.ahk">https://github.com/LGUG2Z/komorebi/blob/master/komorebic.lib...</a>
Very useful program.<p>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.<p>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.<p>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. <a href="https://www.autohotkey.com/docs/v2/v2-changes.htm" rel="nofollow">https://www.autohotkey.com/docs/v2/v2-changes.htm</a><p>I do wish programmers had more options in general for this kind of thing. I ran into <a href="https://github.com/autopilot-rs/autopilot-rs">https://github.com/autopilot-rs/autopilot-rs</a> lately but it is extremely simple. On Windows there s UI Automation, which can help script many conventional apps. <a href="https://learn.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overview" rel="nofollow">https://learn.microsoft.com/en-us/dotnet/framework/ui-automa...</a>
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.
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.<p>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.
I like AHK very much but its scripting language is difficult to use of you do not use it often.<p>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.<p>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.
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?
> > Nested Functions<p>> 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.<p>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.)
Wow! This is exciting! While in my dreams I would still prefer a Rust alternative, sadly there isn't one.<p>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!<p>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.<p>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.<p>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
<a href="https://www.youtube.com/watch?v=aMCP4hyzXwg">https://www.youtube.com/watch?v=aMCP4hyzXwg</a>
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.<p>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?
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?
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.<p>I hope that this upgrade will fix some of these problems. I'll probably take a few years before I upgrade my AHK scripts.
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.