Somehow AutoHotKey is kinda good now
hillelwayne.com
hillelwayne.com
There's works like AutoPy (https://github.com/autopilot-rs/autopy) and AutoPilot-rs (https://github.com/autopilot-rs/autopilot-rs), but they offer like 1/100th the capabilities AHK does.
Personally I think this kind of computer-control is the perfect environment for teaching computing. Rather than writing apps or webapps, I feel like the idea of just writing code to do what you the user would do anyways, but better, is a fantastic introduction to computing & programming. In my ideal world, we'd have an EVE Online server that specifically re-enables the game-client's python interpretter (and periodically does total wipes), so folks can learn to program by scripting not just their desktop, but a complex & interesting game, via it's rich api.
> Personally I think this kind of computer-control is the perfect environment for teaching computing. Rather than writing apps or webapps, I feel like the idea of just writing code to do what you the user would do anyways, but better, is a fantastic introduction to computing & programming.
AHK is how I got into programming. I started with a few hotstrings, slowly added more functionality, a GUI, etc. While writing a specific tool, I learned about ReGex, and would often refer to the RegEx table in the AHK docs.Eventually, I attempted to write a tools to audit network device config with AHK, and a colleague said "why don't you write it in Perl". In looking up Perl, I learned about Python and kinda them at the same time (though interestingly, I still prefer Perl to this day). I also never realised RegEx was a thing people struggled with because I learned it almost immediately after getting into "programming", so I was just part of the learning process.
All in all, I credit AHK with getting me into coding.
My wife, completely put out that I was 'cheating the game' decided that we didn't need to keep up with Farmville anymore. AutoHotKey saved me a lot of time.
But the driving question is whether you can combine A̴̢̤̻͍̤͚̫͒͗̏͒̈́̑̈́͒͘͘̕͝͝u̸͎͉̟͋̾͂̏͝͝t̶̲̳̗̪͎́̔͗̅̓́͌ọ̵̌H̶̪͍̯̯͔̣͎̘̹̿̌͆̍̂̽̊̕͘͠o̶̢̨̦̭̣̤̙̞̘̥̣̫͓͇͛̈́͗̉̃͋̿̊͂̑̅̅͗͝ţ̴͔̻̳̱̫͚͍̳̞̯͋̊̃K̷̬̻̩̯̝̩̯̠̹̝͈͉̙̺̫͋̎̐̇̄̓̇̌̅̋̋̚͘e̵̫̓́y̵͔̌ ̵̱̠͈́̅̌̉̍̑͝͝w̴̦̹̮̦͕͗̂̓i̷̟̫̝͔͍̇͊̉̆͘͘ͅt̵̹̭͎͎̗͕̦͍̰͚̀͜h̴̡͕̮̼̺̟̜͇̺̦̣̑̈́̐̑̚ͅ ̷̛̥͙̲̦̗͓͎̳̖͍̣͓̽͊̊̄̏͒̅̓͌̓͝E̴͇̻̗̱̭̣̐̈͑́ͅx̷̡̨̜̳̯͚̳́̒̎͒͑͒͘͜ĉ̴̻͓͎̬̤̤̖̖̭̱͒̋̂̀̎̌̐͠͝e̶̢̛̮͉̰̣͈̣̊͛̕̚l̶̢̛̛̞͍̬̈̂͂́̂̌̿̇͒̋͝͝ to develop 'database' apps that make people's heads explode.
>AutoHotKey with Excel
This effect is called Zalgo text. I'm one of today's lucky 10000.
I love Autohotkey so much that it keeps me on Windows. It’s the best GUI automation tool out there.
Amen. This is exactly it for me. I'm quite lost without AHK. I have yet to switch to V2 however.I couldn't live without my hammerspoon GUI hacks on Mac (like click and drag to move/resize windows from Linux) though.
- Cmd + Ctrl + <I|O|U> -> Move active window to monitor I, O, or U, respectively
- Cmd + Ctrl + <H|J|K|L> -> Move active window to <left|bottom|top|right> half of screen
- Cmd + Ctrl + <C|V|T|...> -> Open heavy-use application denoted by C, V, T, ...
That plus vim mode in Chrome, VSCode, and Obsidian has me _flying_.
On a whim I asked ChatGPT to generate me some scripts and it works perfectly (at least v1 of AHK). I’ve fully integrated AHK into my day-to-day routine and at this point I don’t think I can switch OS’a without something comparable.
Still have no interest in learning the language, though.
For the many people who say they don't like AHK, I don't think a lot have actually tried to use it. It may be "dirty" but it makes it easy to do most of anything you can think about (it can even call dlls)
For my first attempt, using my arrow cluster, I divided my screen in roughly third: - top left: win+pageup - bottom left win+left - top center: win+up - bottom center: win+down - top right: win+pagedown - bottom right: win+down
Then you just remove the decorations and put windows there, using the coordinates you get.
You can also create toggles, here's a simple one:
WinGetPos, X, Y, Width, Height, A ;MsgBox, is at %X%`,%Y% if (X == 1800-640) { WinMove,A,, 0,0, 1800, 1200 } else { WinMove,A,, 1800-640, 1200-480, 640, 480 }
Extend the logic to use more (or less) of the 3x2 grid.
If you prefer to keep some windows floating:
; Get window style WinGet, S, Style, A if (S & 0x00C00000) { ; If not borderless, toggle all: ; 0xC00000:border, 0x40000:resize border, 0x00000200:WS_EX_CLIENTEDGE WinSet, Style, -0xC40200, A Winset, Alwaysontop, On, A } else { WinSet, Style, +0xC40200, A Winset, Alwaysontop, Off, A }
You can automatize more by hooking to events like OnMessage(WM_DISPLAYCHANGE, "displayChange") which will trigger the function when you move from tablet to portrait mode: just adapt the dimensions.
Look on the forums and you will find plenty of such examples. I've now moved to Linux and roughly replicated some of my setting using hyprland (wayland), but there are many things I miss from AHK
BTW, for the dlls, here's an example of how on Windows 10 the taskbar could be programmatically changed to small icons, then refreshed:
DllCall("ntoskrnl.exe\RtlFillMemoryUlong", UInt,&area + 0, UInt,4, UInt,0)
DllCall("ntoskrnl.exe\RtlFillMemoryUlong", UInt,&area + 4, UInt,4, UInt,0)
DllCall("ntoskrnl.exe\RtlFillMemoryUlong", UInt,&area + 8, UInt,4, UInt,A_ScreenWidth)
DllCall("ntoskrnl.exe\RtlFillMemoryUlong", UInt,&area + 12,UInt,4, UInt,Top)
DllCall("SystemParametersInfo", UInt,0x2F, UInt,0, UInt,&area, UInt,0)
Think of that more or less like changing the CSS then sending `pkill -USR1 waybar`It supports defining arbitrary zone layouts, switching between different layouts with hotkeys, snapping windows to them using the mouse or hotkeys, remembering which zone a window was in, snapping child windows/popups to zones.
It doesn't lock windows in place or remove window decorations unfortunately.
There's some other great stuff in PowerToys as well, they can all be enabled optionally.
* Bulk file rename in the context menu. Rename large numbers of files in a UI using regex/pattern matching.
* File lock viewer: See which process is preventing a file being deleted.
* PowerToys Run: basically spotlight or a system wide version of vscode's command bar. It can do calculations, find files, launch programs. Bound to a global hotkey of alt+space.
* Text extractor: like snipping tool but tries to use OCR to extract text from the capture region.
[0] https://learn.microsoft.com/en-us/windows/powertoys/fancyzon...
The Fluent Search creator is pretty active and available on Discord.
What's the point of wasm when you can just write your machine code to a buffer and call it. Psh, kids these days.
You've just discovered manual JIT ;)
Nowadays I don't have as much need for Windows automation, but I'm glad to see the overhaul. I definitely miss a similar program on other OSes.
I recently built a proof-of-concept for a modernized method of interacting with RTS cameras[0], which unfortunately could not be achieved with frameworks like SDL due to their abstraction obscuring some of the native OS functions needed to create my idea.
Using AutoIt lets me basically just treat it as a minimal-boilerplate sandbox to make DllCalls. This also means that I could directly listen as well as post raw device messages. For example, I implemented an inertia-based cursor script that basically lets you use your homerow vim keys like it's a trackball[1], which I now use everyday whenever I'm not with my ThinkPad.
It has no schema constraints, you can write all code in a single line if you want.
IT NEVER HAS INDENTATION issues.
It never wants you to type in a certain way. Just write and do.
It never assumes, just does the commands as is.
Beginners into programming must learn this. Kids must be taught this. It gets a novice excited to use computers and with its simple syntax, it can be taught in a matter of hours.
As for Python (on the Windows OS) it doesn't come preinstalled, is far larger, less specific to automation, more confusing, and less convenient. There has been numerous Python attempts and projects to copy or make something similar to AutoHotkey and AutoIt, but they never caught on as much. AutoHotkey and AutoIt had already gained a reputation and became more firmly entrenched as the tools to use for automation tasks on Windows.
tcl, like bash, makes some of the same decisions as autohotkey: literal strings are unmarked, while variables to use the value of are marked, and you can invoke commands without parentheses around their arguments
yosef makes a good case that these are the right choices for a command language only occasionally used for scripting, like tcl, but i wonder if they were also the right choices for ahk, however much they may have screwed up the details
like, requiring commas between arguments is probably bad? especially between the command name and its arguments? pv-wave idl is the only thing i've ever used that made that mistake
from the degree of annoyance my wife is having with the & required by scanf in c (she knows more lua than c but the class she's taking is in c), i predict that ahk 2 will not be very popular with ahk 1's audience, who mostly don't know any other programming languages
i'm interested to know what the best alternatives to ahk are for x11 and wayland, even if they do require being a programmer (i am)
I've talked to and read about so many people that needed to do programming tasks, but couldn't or were intimidated by conventional programming languages, that found AHK v1 a lifesaver for them. Many tend to forget or not factor in small businesses, IT personnel, architects, office workers, etc... People who are not trained programmers or whose companies will not pay for the services of real programmers to make job tasks more efficient. That's where AutoHotkey has found a way in, to the joy of many of its users.
While AHK v2 is an improvement in many ways, I think it's also important to not lose sight of why lots of people fell in love with AutoHotkey in the first place. Making programming accessible and easy to use, to solve the problems they are dealing with.
See my post of my windows setup fooling r/unixporn [2] for how it could look.
[1] https://github.com/fuhsjr00/bug.n [2] https://www.reddit.com/r/unixporn/comments/neqnmi/bspwm_not_...
#1 most used feature?
remapping caps lock to do wide text for easy memeing
EDIT: Goddamn it, HN remaps U+3000 to regular space.
I haven't used either for some time now because I don't use Windows much these days, but I tried both and vastly preferred AutoIt. I'm surprised that the author stuck with AHK when he says "AHK v1 was very, very bad.", when surely AutoIt was a viable alternative?
Sidenote: what is it with Windows developers and releasing freware that allows for commercial use but still holding on to not being open-source or at least source-available? The fact that this is still happening in 2023 is flabbergasting.
Open source by itself simply means the source is readily available for reading, nothing more and nothing less.
Being old by itself isn't bad. What's an example practical downside of its old style?
I had been using AutoHotkey for some simple macros before and after reading the documentation with more thought, I set out to mimic some aspects of the tiling WM experience. The outcome was this script https://gist.github.com/ristomatti/f075020025cf870aaf8f73a93.... It looks like a quick hack now (as it was) but I remember confirming it still worked on at least Windows 10 (it was written at the time of Windows 2000 IIRC).
The script is badly documented and I barely remember writing it but what it should support is:
- focusing adjacent windows directionally using win+arrows
- win+left click to move a window around based on a 3x3 grid (click top left moves to top left)
- win+right click to resize a window to grow in the direction of the clicked region of the window
- win+middle click to select a specific window, then win+middle click on an empty space on the desktop to move and resize the window to fill in the gap
- support multiple monitors
https://learn.microsoft.com/en-us/windows/powertoys/fancyzon...
ACs do scan the system, some games IIRC refuse to run in a VM.
I also recall reading about some AC checking if the user inputs seem to be too perfectly timed to prevent botting.
If anti-cheat is okay with AHK in the system, but not running, of course.
I made a script that automatically planted and harvested seeds on a specific shape of a plot.
After that I really haven't found a use for either AHK or Hammerspoon
Would love suggestions.
I wrote an AHK script for it and bound it to a keystroke.
::;shrug::¯\_(ツ)_/¯
If you type `;shrug` anywhere AHK will replace it with `¯\_(ツ)_/¯`.Some things I have hotstring'd: my ACH routing number, my home address (for filling out forms and sending to friends), useful unicode symbols like — and →, the current date in both American and ISO format, common search prefixes, and my personal zoom link.
::tflip1 (╯°□°)╯︵ ┻━┻
::tflip2 ┬──┬◡ノ(° -°ノ)
::shrug ¯\_(ツ)_/¯
and ::email for my email addressI tend to hold the shift just too long in general. Would be nice if I could replace "[A-Z][A-Z][a-z]+ " with the fixed second cap automatically every time.
Language was never good, but it was good for what it was designed for, 5 to 10 liner scripts, but then people liked AHK so much that they used it as general purpose langauge (myself included). For example its still the easiest way to create a GUI, in just a couple of lines of code you can have meaningfull tool window which does things.
With AHK2, the language is way better and consistent (cudos to Leixkos and this decade+ long effort), and it makes other people able to create good libraries for others in it.
You should not miss it. For me, not using it is like not knowing Regular Expressions or some HTML.
Then also controlling some apps here and there, AHK is the fastest tool to get there
Also I have mappings that basically clone all the keybindings from MacOS that I cannot live without, so alt-t is new tab, shift-alt-[ is prev tab, alt-q closes application etc.
It is a nice tool for this because it works on anything you can see (and some things you can't) so if the software can be used then you can automate it. Sometimes you have to fall back on the image recognition sledge hammer but there is always a way out.
Any more complex examples that doesn't work in python / c# that easily?
I think PyAutoGui is pretty good.
I tried using AutoHotKey... I was appalled by the experience.