255 points · by majkinetor · 3y ago · 150 comments
For example, I've been using it for years to enter my Runescape password [1] due to Jagex being clueless about security [2]
[1] https://reddit.com/r/runescape/comments/gxapao/how_to_paste_...
[2] https://www.troyhunt.com/the-cobra-effect-that-is-disabling/
I have 0 patience for entering a password... I'm sitting there in spandex with a fan blowing in my face and I'm holding a wireless keyboard. Anything more than Ctrl+Alt+1 is too mcuh work
KeePassXC is likely the one that's best for most people who wish to go down the standalone application route: https://keepassxc.org/docs/#faq-keepassx
Since quite a while ago now, Tails switched from KeePassX to KeePassXC: https://tails.boum.org/doc/encryption_and_privacy/manage_pas...
So if you're still on KeePass, KeePass2, or KeePassX - consider upgrading to KeePassXC.
The main reason why I recommend regular Keepass, it's because it's usually whitelisted in company owned equipments (with something like Microsoft Endpoint Software Center), so even if you don't have admin or permission to install your own software, regular Keepass it's still available.
I wanted to switch to one with better mobile experience, but the desktop experience in KeepassXC does make it worthwhile
Ultimately the syntax changes make it impossible to fully reproduce the same library for AHKv2, which is being installed by default on all mainstream package managers now.
I ended up biting the bullet and making my own hotkey daemon[2] for use with komorebi based on skhd[3] and I haven't looked back since. This will be the "blessed" hotkey daemon recommended for use in the next release of komorebi.
I'm still using AHK (v1) for the stuff that it's good at (and there is a lot of stuff that it's good at!), but ultimately I've found that it's not the right tool as a hotkey daemon for a socket-based tiling window manager (or just generally, for triggering CLI commands).
[1]: https://github.com/LGUG2Z/komorebi
[1]: https://github.com/LGUG2Z/komorebi/blob/master/derive-ahk/sr...
[2]: https://github.com/LGUG2Z/komorebi/blob/master/komorebic.lib...
Also, will you also get rid of the *.generated.ahk stuff in the next release? It would be far more ergonomic if komorebi can just read and apply the yaml config directly.
The DSL is largely "borrowed" (stolen) from skhd, which has been around for a long time, so most existing shkd-syntax-compatible tools should(*) work, but I think I will take the time to also write tools specifically for whkd in the future based on this comment.
TOML/YAML/JSON are imo even worse than AHK for configuring hotkeys that trigger potentially complex CLI commands. There always comes a point where the user is stuffing an entire sh script into a string and suffering in escape sequence hell.
You can take a look at the feature/whkd branch on the komorebi repo for an idea of how this will look going forward.
Backwards-compatibility with all the AHKv1 generated libraries will remain for users who don't want to move to AHKv2 or whkd, and a new PowerShell generation target will complement the AHKv1 generation targets, finally bringing komorebi full-circle back to the bspwmrc/yabairc model of configuration using a script in the configured system shell (which also launches the hotkey daemon).
As for moving away from the "bspwm architecture"[1] (I think this is what you meant by "read and apply the yaml config directly?) - this will never happen. I've written before about how I feel that the bspwm architecture is the endgame for tiling window managers, and my thoughts on this topic haven't changed.
The komorebi license is pretty permissive so anyone is free to fork it and change it if they dislike the bspwm architecture that much.
I had tried to set it up a while ago but had to give up. Configuration was a bit arcane! I wonder if other TWM are like that as well. I just wanted to upgrade from PowerToy’s zone manager, but the step from that to komorebi was very steep.
Maybe one day there’s a more idiot-proof approach to komorebi! ;)
For the curious, like emacs, my "command mode" is whether or not I'm holding the alt key. Like vim, my command mode navigation is based on the relative positions of different keys. I know that vim uses jkl; for the arrows. I think it is easier to use "ijkl" in much the same way you would use "wasd". But based on position, home, end, page up, page down are included as well as delete. My hands never leave the home row. Technically "alt+j" will map to "ctrl+left" so that it moves my cursor an entire word and not a single character.
quick and dirty annotated map. https://drive.google.com/file/d/1VWXMoh2pN7WrwC5Y2p0BNoYGOzt...
> Alt/Capslock + IJKL is a universal way to get arrowkeys https://news.ycombinator.com/item?id=29162132
I have similar keys to yours, but U and O are left/right four times, and 8 and , are up/down four times. Could make it more, I just know that 3 is to small.
I also use ahk as my window manager, which is essential for working on a 4k 100% scale screen: https://www.autohotkey.com/board/topic/79338-simple-window-p...
I also also have a hotkey for nearly every program I use on a daily basis. Win 0-9 are used of course, but Caps+F1-F12 are also used, and I've recently added Insert+letter keys to my collection thanks to my new fancy QMK keyboard. My goal is to never alt tab again :)
I also also also have an emacs/whichkey kinda thing, which does exactly what you think:
CapsLock & E::WhichKeyMenu()
WhichKeyMenu() {
CoordMode, Menu, Screen
Menu, WhichKeyMenu, Add, &C Code, Code
Menu, WhichKeyMenu, Add, &D Desktop, Desktop
Menu, WhichKeyMenu, Show, % A_ScreenWidth/2, % A_ScreenHeight/2
return
Code:
run, explorer.exe C:\code
return
Desktop:
run, explorer.exe C:\Users\dharm\Desktop
return
}
This is, of course, extensible to any AHK command, not just running explorer. Also means I don't have to memorize every goddamn shortcut. Only weird thing is that I have to exit out of it with Alt. Escape doesn't work and I dunno why.No, it uses hjkl. But of course the spirit of Vim and Emacs is that you can customise these things.
Incidentally, I have quite a similar ‘Vim everywhere’ map, though I use CapsLock rather than Alt to change modes.
You should look into QMK and ZMK-based keyboards and you can set up all kinds of crazy stuff. Sounds like you'd like it.
And it seems impossible to even discuss desktop automation with contemporary Linux DE people, they just glaze over. "Like, why would you want apps to be able to control other apps, that sounds dangerous! We definitely want to protect you from that in Wayland.... Oh, what's that? You are a large consultancy that uses time tracking apps to help with billable hours? I guess you have to change your business model"
Keysharp / AHK_X11 on the other hand ship their own runtimes that will be / are compatible with the actual programming language AutoHotkey v2 / v1 and thus cannot be used in conjunction with other languages, apart from shell invocation. For a detailed feature comparison with AutoKey you will have to research this yourself, but there's at least one feature which is exclusive to AHK_X11 right now, and that is accessibility-related commands such as ControlClick or WinGetText.
It's like asking someone "where am I" and them setting off a contraption that drops a bowling ball on some dominoes that launches a parakeet into a blanket covering a street sign to knock it off and show you. It's all very clever and allegedly safer than just saying it out loud, but also stupid.
Was missing total commander but now that is solved with double commander.
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.
You have all the tools "natively" to even pick positions on windows, its pretty extensive too.
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.
Also I did a quick search and I assume this [2] is the library you mentioned?
That one is also cross-platform, if that’s useful to you.
A real programming language, and support for multiple platforms!
Some things I'm proud of here:
- easy debug console (https://github.com/EBADBEEF/ahkv2-scripts/blob/main/Autostart.ahk#L4)
- compose keys (to type keys like "¿ é ü" easily). Includes libX11 key database parser
- window move and resize with mouse
I love AutoHotkey's documentation. It is an old school windows help file (chm) and it works really well. All my scripts run in an AutoHotKey process that takes less than 2MB of ram and provide great value to me.v2 syntax and features are so much better. It was basically in development for a decade and AHK itself more then 20 years.
I actually think AHK has the better model here. It takes low level windows functions and presents them in a fairly simple and low friction way. MS could never end AHK without also breaking an unfathomable number of other applications.
So how to you create custom keyboard shortcuts with it?
I thought the Mac comparable was Keyboard Maestro. Are the two that different (asks someone who hasn't used Windows since the '90s)?
On Linux I use Wayland but there are several ways to tackle that, involving /dev/uinput. For example there's Python bindings for that and several Rust apps to achieve it. In the end I use ydotool and kbct.
On Android I use MacroDroid.
You can also do some neat stuff with Selenium.
Also AHK community is huge.
That's sort of what AppleScript is supposed to be on MacOS I thought? I'm not familiar enough with either AutoHotKey or AppleScript to be able to compare them though
1. xdotool
2. sikuli
3. AHK_X11
The productivity gains are very real
[0] https://github.com/RheingoldRiver/misc_settings/blob/master/...
All of the places where you use commands no longer need a preceding comma:
Run, Calc.exe
This is now just: Run "Calc.exe"
Similarly, all areas where you use strings now need to be quoted: Send, https://discord.gg/6SNQ4c6
Will now have to be: Send "https://discord.gg/6SNQ4c6"
AFAIK the area where you use "blocks" of code like this: ^!+x::
... stuff ...
Will now have to be enclosed in curly braces: ^!+x:: {
... stuff ...
}
Where you use special constant/strings for the "Send" command now needs to use regular strings: Send "+{Tab}+{Tab} {Space} {Esc}"
Where you do an "if" condition like this: IfWinNotExist ahk_class MozillaWindowClass
return
Will have to turn into something like: if (not WinExist("ahk_class MozillaWindowClass")) {
return
}
A full list of the differences is available at https://www.autohotkey.com/docs/v2/v2-changes.htmI'm pretty sure AHK can direct key presses based on process id or window id.
Unfortunately (or fortunately) I ended up getting into other scripting tools/languages to figure out how to work around certain programming environments.
Coincidentally, my AHK config was my first open source repo on GitHub. I'm glad to see it moving forward.
In general too is there a gallery of great AHK use cases that we can emulate or get inspiration from?
Also found several resources on github. Will dig up the links when I get a chance.
Every ~200ms the script scanned a small portion of the screen where the exit button might appear in and if the script found the button then it would close the dialogue box for me.
This was originally a program I wrote in C for my own use on my ThinkPads some 20 years ago. It turns various keys into mouse movements whenever a mouse button or the Caps Lock key is held down, so you can use the TrackPoint for coarse movement and then seamlessly move the mouse pointer pixel by pixel with the keyboard.
It's a bit like the MouseKeys that is built into Windows for keyboards with numeric pads, but designed for laptop keyboards that don't have that.
When I discovered AutoHotkey, I rewrote JKLmouse using it, and it made it so much better. The code was simpler, and I could make a change and reload the AHK script without having to reboot. I think it is a pretty nice example of some readable and maintainable AHK code.
You can find it here: https://www.jklmouse.com/
There is an installer, but I haven't kept it up to date. Instead I recommend installing AutoHotkey directly and getting jklmouse.ahk from GitHub and using it as an AHK script.
Now I have to see about updating the script to work with AutoHotkey V2!
If you have a stack of items, you can pick up half of them by right-clicking on it, which is very convenient when you're dividing out a stack on the crafting grid to make many copies of a recipe that needs that item in 2 or 4 slots; but for some recipes, you need to put the same item in 3 or 6 slots, and there's no built-in way to divide a stack into thirds.
So I made an AHK script that, when I held down a key, would
- pick up half of the items in the stack I'm pointing at (right-click) - move the mouse one inventory space to the right - put them down (left-click) - pick up half of them again - move back one inventory space left - put them down, adding them back to the original stack - and repeat
and it would only stop after one of the "pick up" steps; so, after a few iterations, you'd be left with the stack divided into equal thirds, two in your inventory & one on the mouse.
Eg, starting with a stack of 60, it goes 30/30, 45/15, 22/38, 41/19, 20/40, 40/20, 20/40, 40/20... then release the key, and you've got three stacks of 20.
Battlefield 2042 recently had an XP glitch where you could go into a server with BF3 settings, throw ammo to a teammate and get XP for the resupply. Naturally there were several servers dedicated to this with 128/128 players and everyone on one team all standing at one objective.
Rather than actually play the game to level up and get the weapons/gadgets I wanted or even play this accelerated XP mini game, I wrote an ahk script to automate the equipping and dropping of the ammo crate so that I could do other things.
I only had to let it run for a few hours before I was max level, and the 10 minutes of scripting gave me the benefit for something I wouldn’t otherwise subject myself to.
I created an AHK script that binds other, convenient key combinations to those characters. Now I can type them.
I've also used it to quickly enter lots of data into a native application that only supported adding one item at a time.
Unless by 'tabs' you mean 'instances' or 'windows'?
I just asked ChatGPT how to get the currently selected file in the current tab of File Explorer in AutoHotkey and it spit out code that works quite a bit differently than mine. Later today I’m going to figure out what it’s suggesting and see if a different approach is needed.
——-
The ChatGPT code is nonsense that looks like AutoHotkey code.
I was around the forums a decade ago and it was a wonderful place.
More importantly its considerably larger and slower.
Have you looked into something like this[1] for generating the macro as an ahk file? Full disclosure: I have not used it, but it seems like what you’re looking for. If you find that it suits your needs, I’d use that to record the macro and then wrap it in a loop from 1..N where N is based on the Fn key you press. That should do the trick unless I’m misunderstanding.
I wish I could be of more help, but this repo seems like a decent starting point for your use case.
Apologies if the formatting is poor as I am on mobile.
It is really a time saver.
My muscle memory still wants me to middle-click in a Finder window.