Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I saw there's a python library that just lets you write autohotkey scripts in actual python code. I'd rather try that if I was going to rewrite my v1 scripts. AHK is awesome but the scripting language was never good. The new one looks like it has some better syntax, but native python support would be a much better solution for a lot of people.


Why? The AHK python library isn't going to be so cleanly abstracted so that a different automation engine (eg hammerspoon w/ lua on macOS) can be plugged in, so the code is always going up be tightly coupled to AHK, and Python support is likely to be second-class to support for its own language. So other than some obsessive need to standardize on a single language which will never be won, what does Python buy?


Python buys into pypi, which has a 6-digit number of packages, e.g opencv can read your screen to find buttons, etc.


I realise you are giving opencv as an example of why having Python to AHK would be desirable, but for anyone wanting to read GUI elements like buttons there is ImageSearch[1]:

Also, to make it even easier to generate AHK scripts to automate button clicks, clicker games, or boring tasks requiring the keyboard and mouse, you can generate an image recognition AHK script quite easily using Pulover's Macro Creator[2]. Even someone with minimal knowledge of scripting can use it to automate Windows.

Even without Python, AHK is amazing. It gets a lot of undeserved flak from advanced users, undeservedly so in my opinion.

[1] https://www.autohotkey.com/docs/v1/lib/ImageSearch.htm

[2] https://www.macrocreator.com/


No flak intended, AHK is much easier for non-programmers and can do more than you’d think. I’ve show a few people how to rig up an automation in a few minutes. The bar to entry is much lower than for any of the «serious» languages out there. AHK is amazing!


AHK was my introduction to programming. I’m a bad speller and I wanted certain common errors I made corrected automatically. I had a very basic but fully functional program in literally minutes. I spent the next few days adding features, and it was amazing to me how someone with zero programming experience could translate my thoughts to code.

This is what makes AHK special, I’ve never seen anything that can abstract away everything between the code and a fully functional program so well, making it an ideal learning language, especially for children and others with very little technical experience.

I don’t use AHK too much anymore as it’s limited to windows, which is a real shame as I’ve never seen anything better for quickly creating UI automations and tiny programs extremely quickly.


Syntax


I really don't see how AHK's script language is somehow not intuitive or simple enough. The syntax is pretty easy to grasp.

You have all the tools "natively" to even pick positions on windows, its pretty extensive too.


I write AHK scripts like once or twice and then forget about it. I can't remember the sytax so I'm constantly googling. I'd rather have it in a language I already know well. Also as a long time programmer who knows a lot of languages, the AHK syntax (at least in V1) was anything but intuitive. It had very weird conventions.


I find the syntax easy and the documentation (of v1, not enough experience with v2) is easily accessible and of high quality. V2 solves some inconsistencies in the syntax and language but at the cost of being compatible with v1. I've been able to port my v1 scripts to v2, and I'm a lousy programmer.


Fair enough


The syntax is a nightmare. I honestly never understood why they made it so complicated.

Should I use a brace? On the same line or on a new one? How to pass parameters, with or without paranthesis? Should I use ::?

There are many such issues.

I love AHK but every time I wrote a script or is trial and error to discover the proper syntax.


In today's polyglot software development world, one real difference between someone who's a programmer and a software developer is fluency in multiple languages. That might come off better when it's Python and GoLang/C++/Rust instead of AHK, but realistically, every domain has their own DSLs.

A competent software developer should be able to check their ego and use curly brackets instead of PEP 8 4 spaces if that is what the situation demands. And also be able to resist the urge to reformat an entire Python codebase that was written to 2 spaces.


Who's using AHK as a developer? I use it a a hobbyist. I don't want to have to remember a proprietary useless language syntax.


Coming from an ahk user circa 2010, I have never been able to wrap my head around pythons insistence on indentation. Ahk let's me type whatever however and it just works.


Honest question, why? If you properly format your code then it's indented anyway so Python is basically just replacing `{` with `:` and then not having a `}`. Python is the least problematic of all the languages enforcing some style things. Go insisting on Google's stupid styleguide is just dumb, Lisp having the parentheses on the wrong positions and ignoring the fact that there is more than one bracket type available is dumb, all the languages with `END` blocks are dumb because `{ ... }` is much shorter and cleaner, ... . Python has its annoyances too but indentation really isn't a problem - it's there already anyway.


as i said, i am not a dev so i never learned "convention"....

AHK let me scrap whatever script from internet or i could come up, throw them in notepad and it would work.... now, python makes you "properly indent" which coming from AHK makes my head explode

https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2F...

this is a good example. AHK would read this normally but no, python sees whitespace and wants to "use that"....

https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2F...

this would never happen on AHK so it makes me mad.

part of the reason why i have never gotten hold of python while i can whip up an AHK script in my mind


Fair enough, I can see that this is something which can easily throw you off if it isn't part of your normal workflow.


I wrote MicroKeys[1] out of a similar frustration. Granted, I never got past the POC stage, so it's not as feature rich as AHK, but it solved a very specific itch I had. I debate if I should flesh it out further, or try using AHK again.

[1] https://github.com/seligman/microkeys


I've been using SikuliX [1] instead of AHK for a while now, only downside is that it uses jython so it's stuck on 2.7, but I don't use it for anything complicated enough that it really matters. Also I mainly use it for long running, rarely used automation, so I'm not sure how it would compare in terms of responsiveness for tasks like text expansion.

Also I did a quick search and I assume this [2] is the library you mentioned?

[1] https://github.com/RaiMan/SikuliX1

[2] https://pypi.org/project/ahk/


Pyautogui? https://github.com/asweigart/pyautogui

That one is also cross-platform, if that’s useful to you.


That doesn't seem to do any of the hotkey, hotstring etc. stuff that is AutoHotKey's main purpose.


In case you're open to something for JS instead of Python, my life has been much better since I switched from AHK to nutjs for my own automation scripts: https://nutjs.dev/

A real programming language, and support for multiple platforms!


Alternatively if you're into dotnet, FlaUI is amazing for automation and gives you a sane environment. I moved to it when I couldn't deal with AutoIT scripts anymore and it's everything I needed. https://github.com/FlaUI/FlaUI




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

Search: