Wow, the one time in history I may be able to contribute something useful to a code-related discussion. I set up this script so I could quickly and easily open a blank plaintext notepad.exe instance at any time, which is super useful as a writer. When I hit tilde it opens, when I hit tilde again, it closes, with a save dialog if anything was written. It's the only thing my AHK does!
I like the detail how the very same key (just mostly in combination with meta/windows key) is kinda idiomatic toggle for terminal, what most programmers "live in". I wonder if digital graphic artists happen to launch their scratchpads or paint programs in a similar manner.
Btw, for use-cases when you need to keep the "toggled" window opened and do not want to close, minimize or hide it or something and just need the fastest flip to, flip back to previous window "toggle", super useful but (for me) long time forgotten native Windows hotkey is *`Alt + Escape`* - it simply switches to previous focused window without even showing window overview (like Alt+Tab).
So AutoHotkey *v1* boilerplate for such switcher/launcher then could be something like:
Or if you do not want that window to clobber the taskbar, you can use `WinHide` instead of that Alt+Win `send, !{escape}` and add WinShow to WinActivate, but it does not work well with some kinds of windows. Also for window detection it may sometimes be more suitable to use `ahk_exe` or `ahk_class`.
I do include Minimize-if-already-active though. I like to be able to temporary flip an application into focus (e.g. Outlook) and then return to what I was previously working on.
Plus a tweak: When launching, programs may open in the background because Windows attempts to prevent applications stealing focus when you are working in another program. I overcome this by focusing the tray before launching.
It uses AHK's window groups.
I only regret having written this in AHK v1, which was a bit of a pain in the neck.
I intend rewrite them in AHK v2, which looks like a halfway step to ES6 with lambdas, closures and all. So many quirks gone! I tried it a bit and it felt more fun and productive.
As a simpler alternative (which I use for work), one can pin the 10 most used applications on the taskbar and do:
- Win+<N> to launch, toggle, or choose a window from the Nth application
- Ctrl+Win+<N> to launch, toggle or cycle through the windows from the Nth application
- Shift+Win+<N> to launch a new window
- Alt+Win+<N> to bring up the Jump List
Then you can use a simpler hotkey manager (like PowerToys' Keyboard Manager) to bind to the Ctrl+Win+<N> shortcuts.
> Plus a tweak: When launching, programs may open in the background because Windows attempts to prevent applications stealing focus when you are working in another program. I overcome this by focusing the tray before launching.
Aaah! That explains some things. That does happen to me sometimes and it's a bit annoying. I got used to pressing my hotkey again when I noticed the taskbar icon blinking green to bring up the new window, or just spamming WinActivate and hope for the best. Thanks!
Yes, Win+<number> is also a gem that almost seems to be deliberately hidden, (like Win+T, Win+B). One thing that helps is to see actual numbers in the taskbar, what, to my knowledge, is currently possible in Windows 10 (only) with third-party app: https://ramensoftware.com/7-taskbar-numberer . For startup
will show same number for grouped windows so cycling will work.
Btw most tabbed interfaces have the same bindings for focusing first, second ... last tab (Ctrl+<number> in most browsers, Ctrl+9 for the last tab, usually).
I like to apply same "tab principles" to taskbar, so last thing missing here is to be able to "Ctrl+PgUp/PgDown" through windows in Taskbar order just like in sane browsers (with Win in place of Ctrl).
I attempted to do it with AHK but failed miserably, but luckily another third-party app, (7+ Taskbar Tweaker, from the same author as Numberer) can do that through advanced settings. Config in gist: https://gist.github.com/myfonj/62b4e0d393f4a97df5e9904df5e77...
(Sadly, none of those will probably ever work outside Windows 10 (?))
Ah, sorry, my bad, it should have been "Escape" instead of ~"Windows key"~.
`Alt + Escape`, that is. Thanks for pointing it out. Corrected.
(You see, I almost never use this shortcut directly, b/c I only exploit it in those AHK scripts to do the "to previous" flip without doing any additional persistence or querying in the script, so I messed up when recalling it. In fact I thought it was `Win+Escape`, tried it, found out it was `Alt+Escape` instead, and then finally wrote `Alt+Win`. Bad braining today.)
This is only slightly faster than hitting the Windows key, typing "Notepad", and hitting Enter.
Would be cool if it opened a single "notes.txt" document instead. That way you could bring up your notes, append what you want, and save/close it with a single hotkey.
It's about minimising friction in our tasks and reducing any unnecessary obstacles. Even seemingly minor actions that only take a few seconds can build up over time and generate a sense of frustration, especially when they become frequent.
Personally, I have found that dealing with this kind of friction can erode my overall productivity, as I unconsciously shy away from these tedious tasks that involve manual repetition, no matter how small. That's why many of us choose to invest a little time in coming up with these small automations that free us from the clutches of monotonous and repetitive tasks, allowing us to focus on the core of our work.
Autohotkey is amazing, but I wish it used a saner language. I struggled to write a reliable golden ratio version of aero snap [1]. Dealing with different monitors, sizes, etc doesn't seem like it should be so hard, but I always get tripped up by the bizarre Loop syntax or silent failures from some simple mistake that suck the fun out and I give up.
I found ahk python module [2] but combining it with the keyboard module doesn't work as well as autohotkey as a hotkey listener.
That's why Autohotkey v2 exists, which is... AHK's own Python3 moment, since it was available for years. Well, ok, stable release was only like a year ago, but I don't see much adoption.
TFA uses V2. I also started using AHK just in time to use V2. Of course it will take time for all the V1 users to migrate, but for anyone starting now it makes little sense to use V1.
I believe I’m using v2, since I written most of my scripts last year by most recent documentation which mentioned “old ways” sometimes. But it didn’t make a big difference in that regard.
Part of the problem IMO is that AHKv2 is magnitudes better if you're a programmer, because it makes the entire language consistent and sane. But if most users aren't programmers, so they don't have the same burning incentive to switch.
it's just a bit tedious to convert even with the help of a converter, especially when you're dealing with libraries which you didn't write, but still very much worth it (you could maybe also do a lot of the conversion piecemeal and just run both for some time)
You know, that's part of what's been holding me back from using it for much besides remapping CapsLock to Control. Maybe it's time to sit down and write a Lisp DSL that compiles to it.
Or make it call a cloud service running a real program in a kubernetes cluster, which gets the hotkey and returns a script to interpret. If AutoHotKey does not have network and eval functions, they must be added ASAP
For my wedding I set up a "photobox" with AutoHotKey. I took a simple software to control my fiancees Nikon via USB and IrfanView on my Laptop.
I configured Irfanview to monitor a folder and always show the newest picture.
Wit AutoHotKey I made a simple GUI with 3 Buttons. Preview, Autofocus and "SNAP". Preview brought up the camera software in liveview mode. Autofocus triggered the Autofocus. "SNAP" brought up a large countdown, at 0 it triggered a photo. The it minimized the camera software and brought up IrfanView. After a few seconds it "reset" itself, so IrfanView got minimized and my button GUI got brought up again. My guests loved it and I saved hundreds of Euros for renting a photo box and I got great images out of it.
I didn‘t build a box itself. It was just the Nikon on a stand with a flash directed to the ceiling for better lighting.
My laptop on a small table infront of it to control it and work as a display.
That's great. I hadn't noticed it's has been added to PowerToys. I can now finally retire my 7 year old script. Hopefully one day it will be promoted to be included in Windows by default.
PowerToys can be iterated on much faster than the Windows release cycle, and without needing the same support commitment. Plus, some of the features do "graduate" in a sense, like Snap Assist https://www.windowscentral.com/how-use-snap-assist-windows-1..., which is basically a watered down version of Fancy Zones.
It is so strange that pasting with formatting is the default! I have so far never wanted to paste with formatting a single time. I dont even understand what use case it is addressing.
Honestly - Depends on the Job. When coding, I generally want ~no formatting by default. But When I'm pulling a code chunks into an email or similar; to preserve easier readability I can either copy from terminal with formatting or send a screenshot (which recipient then can't copy if they want to play with it). You could say "Use a different tool!" like Gist or similar; but that's often overkill.
On a daily basis, i paste into programs that aren't wysiwyg (terminal, reddit, browser omnibar, etc) much more often than stuff that is (google docs, powerpoint). for the former programs it doesn't matter if i paste with or without formatting.
for the latter programs having the default be paste with formatting seems fine. yes, i'll paste stuff from the web without formatting. But copying/cutting/pasting within the same document is also a pretty common interaction and if i'm cutting something non-trivial (eg. google docs table/nested lists), i don't want to paste it back into google docs as a bunch of regular, separate lines.
My complaint is that I can't reorder the items so that an older clip is back "on deck" for a vanilla CTRL+V. Some programs (gVim) don't take too kindly to WIN+V.
I use it in Mac as part of my job duties. So far it mostly works in the place I need it most which is web forms on chrome. Some applications I wish it worked on do not recognize it such as notes app.
I'll have to figure it out on Mac since ahk was my go to when I had pc
Opt-cmd-shift-v is the (rather unwieldy) macOS shortcut to paste without formatting.
I have cmd-shift-v mapped to my clipboard history which is fully searchable, I use Raycast on Mac but I would wager there are Linux and Windows alternatives.
AHK is one of the apps which locks me into using Windows. I use it to add characters like äöüß and áóúñ to my keyboard, to control the light level in the room and apartment, add timestamps like `08:39 –`, `2023-08-22 08:39:46` or 2023-08-22 — Tuesday` with the press of one/two buttons, shut down/turn on the power to my monitors with a Tasmota enabled power outlet when toggling the pause key and some other stuff.
I only wish it had the capability to use a second keyboard as a button surface to trigger stuff while eating up those key presses, so I'm resorting to a small bluetooth keyboard connected to a raspberry pi zero in order to get more buttons.
It’s interesting seeing people in this thread complaining that AHK keeps them tied to windows, I feel the same about Keyboard Maestro on my Macs.
I switched to a 90% Windows environment at my new job. Gave Windows + AHK a shot to potentially reduce headaches when IT issues would pop up.
I couldn’t do it. AHK’s syntax is ridiculous, and whenever I would try to download and trial scripts I had to infer if it was v1 or v2. I switched back to the Mac with KM and am much happier for it.
If it's worth the money you could look for a cheapish keyboard with support for QMK or any other custom firmware and map some buttons to either F13-F24 or hard to trigger combos like ctrl-alt-shift-P or the like.
I wanted to comment this (Tom Scott used it to map buttons across 15 keyboards to unique emojis on a single computer) but it looks like as of March 2023, Luamacros has been abandoned :(
> Let's officially state what has been a reality for the last several years. I don't use Hidmacros/Luamacros any more and have no interest in improving it or even fixing existing bugs. I invest my personal time in other things which are more interesting for me now. So please don't expect any support from my side. I'm also removing all donation buttons.
With AutoHotInterception AHK can differ between different keyboards/mice based on their hardware-id. You can have a separate keyboard with it's own layout, macros, etc.
i switched to linux a few years and it was really tough losing the 5 years of ahk scripts i had built up, but windows was annoying me that much that i had to switch.
you need multiple programs on linux to do something similar to ahk and nothing ive tried has come close to how simple ahk is or how you can make complex key mappings with it.
i have got into python though and have been able to do some fun stuff with that so there's that at least
In Windows, everything is part of the operating system. You just set the window flags, you just beep the audio, you just send WM_CLOSE, you just disable MouseKeys. In Linux, everything is a specific program, with a name, and with commonly used alternatives. Your program to move a window to a particular location must be compatible with the program for having windows at all (X or Wayland), the program for laying windows out (dwm? KWin?), and probably the program for the desktop (GNOME? KDE?). The net effect is one where a user is probably able to write their own AHK-style scripts, but sharing them around is basically impossible, and figuring out what to do is much harder due to navigating a forest of tool-specific documentation.
25-key MIDI controller? There are a few people who have gotten AHK to send/receive MIDI, and you can pick up a cheap B-stock controller for far less than a mechanical keyboard.
I have a Preonic keyboard running QMK[1] and have a dedicated MIDI layer so I can still use it as a regular keyboard if I want to. I then use dannywarren/AutoHotkey-Midi[2] to listen for hotkeys.
This has been way more reliable for me than listening for trying to use hotkeys like Ctrl-Alt-F13 or things like that, as they'll never conflict with something I might be in the process of typing. The only catch with that is if you want to use AHK to send keystrokes to a process running in elevated access, you'd need to start your AHK script as Administrator. That hasn't had an impact on me, though.
- Insert date/timestamps shortcut (6 different formats, including ISO, and filename-friendly)
- PuTTY/SSH launcher shortcuts for often used hosts and serial ports
- Stateful DWIM Application Launcher for 10+ applications, e.g. Outlook (Win+O), Windows Terminal (Win+Space), Total Commander (Win+T), etc. (Either launches, activates, or minimizes depending on current state)
- Paste clipboard in plaintext (no format) in any aplication (Win+V)
- Paste clipboard removing newlines in any application (Win+Alt+V)
- AltGr input layer for special characters (æøåµΩ° and some emojis)
- Media & Volume shortcuts (start/stop/next, volume up, volume down)
Mind sharing these? My current job includes a lot of manual copying, at least until I can automate it. Especially the plaintext/no newlines paste sounds very useful!
I have swapped Caps Lock and Escape on my Linux personal laptop and I have grown used to it. So when I dual booted Windows on my machine, I used Powertoys[1] to achieve the same.
At work, I have no option to install Powertoys or Uncap[2] for that matter. AutoHotKey is the only way, but I'm unable to get it to work. I used this StackOverflow[3] answer, but with this, both Caps Lock and Escape send both of the keys. So I'm stuck occasionally messing up my Teams messages :)
With home row modifiers, Shift/Ctrl/Win/Alt are put underneath fdsa (and jkl;). -- This reduces the need to use pinky fingers for these keys, & the fingers get to remain on home row more.
Did you try scancode map registry[1]? I use it to swap Ctrl/CapsLock and it works well even with RDP softwares and run-as-admin apps which PowerToys couldn't handle.
As others have rightly noted AHK is amazing for what it lets you do on Windows.
I've easily saved/earned over 100k USD from AHK.
However, the AHK language is not the most pleasant to use.
That leads to question why isn't there something as powerful available in Python
or say Lua.
Yes there is https://github.com/pywinauto/pywinauto but in practice it did not work as well as AHK.
It is just WinAPI underneath so C# would be another choice if there was a nice wrapper library.
I guess the answer on why AHK is so popular is that it is ugly but it works.
Upgrade to v2 if you haven't yet! It was just released earlier this year and makes the language a lot less ugly. No more command/function divisions, everything's just a function!
The reason AHK is so popular is because the ugliness that most “real” programming languages won’t tolerate is what makes it so approachable in the beginning.
PyAutoGui is very good. I have been using it for a long time and rewrote some simple ahk automations with it recently. It's strictly not a one-to-one replacement (so I still use autohotkey) but the UI automation features are well-done.
AutoHotKey is awesome! I use it for better/faster app switching. I have a "shortcut" enabler key, in my case Right Alt, that controls it all.
When held down with any letter, it switches through the instances of that app. For example, Alt + C switches to VS Code window. Alt + F keys opens new instances of an app such as a new Chrome window in a specific profile.
Alt + number are configurable and can be set for the current window in focus. By tapping Alt, the "edit" mode is enabled, allowing me to set the current window as any of the number keys.
When in "edit" mode, the H,J,K,L keys also switch to navigation, becoming up, down left, right etc.
I don't have anything shared online but I can look at publishing it if there's interest. It's one big script so I'll have to clean it up and remove any sensitive data from it first.
The most impressive script I found and modified at some point long ago was while playing Diablo 3. I had been getting a bit of an RSI issue because I was pushing my mouse hand too hard into the mouse pad, so I looked around for some means to play it with a controller.
The script would bind your analog move to a little circle around the player, allowing you to smoothly run in any direction. You could then press a button to alter the range to distant for casting abilities further away. With just a bit of customization per class it worked amazingly well.
The AHK documentation is really good, and is a windows help file (chm). It is really fast, has a good enough indexed search, and example code is usually present.
Every time I consider trying to take up coding, I remember that I have tried to write the most basic AHK scripts possible and cannot even get going with the tutorials. I find it completely impenetrable.
For me AHK is harder than other programming languages I learned (python, JS...).
Took me a while to figure out a decent environment for it:
VScode with Autohotkey Plus Plus extension, which allows debugging.
+chatGPT is super useful for it.
so don't get discouraged. If you want to learn coding I'd recommend learning python on some online code editor which requires zero setup. lookup 'python online', there are many websites for it. also Google Colab is awesome
ChatGPT is actually pretty good at writing AHK scripts except it always writes a mixture of v1 and v2 syntax. Even if the script it creates won’t run, there’s usually enough to get you 80% of the way there.
The most useful thing I’ve made:
Select text anywhere and press ctrl-shift-1. Select text somewhere else (even in another application) and press ctrl-shift-2. Press ctrl-shift-3 and my graphical diff tool opens to show me the differences.
ahk is fairly forgiving though compared to other languages. i found it harder to get into python even after years of getting proficient at ahk, and python is supposed to be one of the easier languages to learn.
maybe you just need to search online more or refine you searches. when i was learning ahk first i would nearly end up searching nearly every little thing i needed to do, and there was always a forum post with the answer or part of the answer
I've written more then 5000loc long program that plays an MMO for me!
It can already do most of the content that's in the game, but there still a lot of improvement needed.
But the development was so fun, every night I would start the script and then when I woke wake up, I would see where it broke and could then try to fix it and test it again the next night (because a lot of in-game content rests daily).
When I started writing the program, I was looking around to see if there's a library for Rust that would give me the same or at least similar functionality, but sadly I didn't find anything.
Don't get me wrong AHK is amazing, I just wanted to use the coding of this program as a way to better learn Rust!
I even had the program write a CSV file so that I could track the effectiveness of farming.
It really is incredible how powerful and easy to use AutoHotKey is!
> I've written more then 5000loc long program that plays an MMO for me!
Interesting, that's how I got into AHK and programming in general too. It started as a simple timed clicking script, then became dynamic enough to handle variable timings, then I sped it up by embedding compiled machine code from a C function into the script as hex, decoded into a buffer, and called it with DllCall so more computer resources could go to running the game rather than the script. I went into more detail about my story here: https://news.ycombinator.com/item?id=23160930
Crystal Saga, it's a flash MMORPG as such it used to be browser based, but now you need their launcher or a non-mainstream browser. I do have hopes that Ruffle will bring the game back into modern mainstream browsers, but it's not quite yet there.
That doesnt change the fact its simple cheating, getting an unfair advantage against other players. Beside this, botting is not what AHK is really good for
I wouldn't go that far. A lot of games have drudgery built in which isn't exciting past the first few times you've played it and rare bouts of willingness to do it again.
I would position part of what made Diablo 2 (not remake) last so long was bots on the ladder and the shops that provided the bots; no one "new" was playing the game at that time and everyone had "fair cheats" for rushing through the first two game modes [0] [1], and everyone had been using the "fair cheats" for years since they had been discovered. But the fair cheats needed other players to pull off, and this wasn't always reliable.
When the D2 shop farmers started botting, they realized it would be great advertisements to do specific types of common runs for leveling with the bots; the bots would grab any item worth value, but typically they just would repeatedly run common leveling/item farming areas on a predictable and guided schedule, dropping quick announcements about the shop in chat periodically (maybe several times per run which is usually around 5-15 minutes, and it was just a quick stylized message in the game chat.) There were enough bots that it wasn't flooding the available games to join, but you could almost always find a bot game to join and just follow until you were leveled.
Most players did this to get through Normal mode and often nightmare, as everyone just wanted to get a character ready for late Nightmare/Hell which is when the game is "fun" (better drops, more difficult monsters to fight, it was the point at which the game gets interesting in general for most players)
Without the bots and players "cheating" through the first 2 game modes, I'm not as confident people would have keep playing as long as they did. It wasn't "unfair" in my opinion as everyone had always wanted this, and it had automated what everyone was already doing; I'm not sure I see the difference between using AHK like the GP did and having a setup like what D2 had
0 - For the unfamiliar, Diablo 2 had three modes: Normal, Nightmare, and Hell; same game each time, but item drops are better and monster levels are changed to be more difficult, with monsters getting better attributes that made them more difficult. I am going to make a generalized statement that for most players, the game really begins at Nightmare if it's not one of your first few times playing the game
1 - By "fair cheats" I mean the game was exploited to ensure fast leveling without a lot of effort and also ways of bypassing the "boring" parts of the game that the game allowed, but likely not intentionally. Blizzard definitely couldn't solve this in game without substantial reworks, which they probably didn't want to do
I dont know about which years you talk about but at least in the early 2000s it was probably most common to let yourself be lead through Normal/Nightmare by others (e.g. clan members), which was a very nice part of companionship that helped foster engagement (and thus play count). But maybe you and me were just in different bubbles...
Not sure you'll see this, but I played from release until they released D2:R (I want to play D2:R, just no time :) )
Early on that's how it was, but later on they figured out glitch rushes (grushes) to help you fly through a1-a3 and you'd usually just trade your forge on NM/Hell for it.
After awhile though, this got really scammy from my experience (too many players who needed to be rushed would just flake)
Around 2018 or so when I played again, there were a LOT of shop bots running around doing the runs, and even better you had ENCHANT games where some suped up sorc would cast a ridiculously leveled ENCHANT on you (and your merc!) and even get you waypoints. I think I even remember the bots could do the grush, but I'm not confident I remember right on this element.
Basically, yes, old team-ups were great, when the player base was significant enough that you could do this :) In the last years of D2/LOD original, it was a little less possible to go that route.
The game that I play is called Crystal Saga. And while technically it is cheating, you don't get any real advantage doing so because the game it's designed in such a way that you can but pretty much every item with real money and many systems used to upgrade yourself can only be used by spending more money.
As such even if you were to automate every part of the game that's you can do as a free to play player you couldn't get close to those that support the developers with their money.
The gap is so big that you can't even hurt those players where as they can pretty much kill you in one shot.
But I personally play the game because of the people and the community, so none of the automation or money spending really matters to me.
I love AutoHotkey, it basically gave me my start in this career and still makes me occasional commissions to this day. My current "Dave's Utilities" AHK is rather lean compared to times gone by, but I have these "essential" functions always a keypress away on my Win11 installation:
- ctrl+alt c / n / s for calc / notepad / snipping tool
- toggle "always on top"
- send to "other" monitor (I have a 2 monitor side-by-side setup)
- turn a Youtube "shorts" url in to it's regular Youtube page "watch" version via URL manipulation
- remap ctrl+shift+c to do nothing, instead of very slowly opening Chrome dev tools when I miss ctrl+shift+v "paste as values" in my huge Google spreadsheet
There is a native Windows shortcut for Send window to next/previous monitor: Win + Shift + Right/Left arrows.
(Windows recently got bunch of keyboard shortcuts, some overridable, some not. Sometimes you can discover them only with your AHK disabled, since you might have overriden them in the past...)
Back when Lenovo ran their outlet for refurbished laptops on very database heavy oracle backend (2011?), our little computer shop would buy stuff from them. If you added an item to your cart, it would hold it for 10 min and prevent others from purchasing.
I used AHK to script a process that would automatically add laptops to our cart based on certain search criteria. Then we could sift through their inventory and release what we didn't want.
It was running great until one day it went rouge (okay, was prob human error) and it added EVERY item to our cart and crashed their website. Database error came up, I called them and told them what I did and they were happy to know why it went down.
Every AHK I've made has gone rogue because I want it to do things and it does it well but without guard rails i overwhelm my target every time. Thankfully the target is usually my local and I just mostly reboot
You'd think I'd learn but my scripts usually start small for with one specific use and i enlarge it Unsafely once I think of another use for it
Loops are my danger zone. After a few crashes the first guardrail I end up adding to a script is a stop key combo interrupt. Then figure out what bounds to put only after every mistake. I don't have the foresight to prevent "rogue" behavior
We built Text Blaze [0] a Chrome Extension [1] that supports a lot of similar capabilities.
It lets you do text expansions on any website using hotkeys, include dynamic values like the date a week from today in your snippets, build form UI's [2], and include dynamic logic using formulas and if-statements [3] (it uses a dynamic reactivity model for formula's similar to spreadsheets).
One thing we are really excited about currently is using Text Blaze snippets to connect any website to an Airtable/Monday.com like spreadsheet using a lightweight SQL variant we created [3]. Combined with forms and formulas, this allows you to build mini-apps you can use on any site with a hotkey.
i learned my first "programming" by doing autohotkey.
you write code line by line and the software expects to parse it one by one.
imagine my surprise when trying python for the first time and indentation error. WTF does indentation has to do with code?
i still cannot get over the fact that some interpreters and compilers and shit look at whitepace and go "this should be 4 space and not just 1 or 0. boo. wont run".
i get it, there has to be some form of beatification and stuff but why the hell wont the program run without proper indentation?
i have a problem at work, something tedious and my mind can think entire AHK programs. all i have to do is type them out and run.
Python uses indentation for nested scope (I think that's the right term). While other languages might use curly braces or even keywords like do and end to enclose loops and functions, Python uses indentation. It ensures code is readable, but coding newbies have to learn about whitespace errors AND scoping together. It's one of the parts of the language I dislike the most.
It's weird how python defaults to spaces rather than tabs, as tabs would make indentation errors less prevalent and a lot more obvious to people learning the language.
It's like learning to write but not wanting to learn punctuation. You might end up with the Ulysses but more likely than not you'd end up with something that other people and yourself won't be able to understand well when you look at it on the next day.
That said, I'm in the camp of curly braces (or equivalent) plus an autoindenter. Either a code formatter or the editor itself.
Braces and random indentation is the worst that can happen.
Scoping is essential for general purpose programming, so it is usually fused into the syntax of any GP language in a form of {…} or begin/do…end. Python is one of the languages which try to remove this character and keyword noise based on observation that to see scoping people usually correctly indent their scopes, so python makes indent itself important.
I can recommend using Notepad2 if you want to use GP languages but don’t want to use an IDE (which is understandable as it brings a cognitive overload when you learn). Notepad2 is a drop-in replacement for Notepad, but may be installed as a separate app. It’s not particularly for programming, but has related features that Notepad should have had for ages.
look up a random autohotkey code. you can write it sideways, it will work. you can write it with indentation, it will work. it will work if the whole code is in a single line.
on one hand, it has the least amount of startup for a new programmer because it can teach you to do cool things.
on the other hand, like me, the "habits" get wrong because i never learned to do pretty code.
It's like learning to drive the car whilst sticking to the rules of the road and staying under the speed limit. It's not supposed to be fun.
Besides, I don't know what backwards IDE you used. I've been doing python for 15 years and have never had to manually indent squat, ever.
It sounds more like you didn't actually try python but read about the whitespace indentation somewhere and decided to chime in. Either that or you tried it in notepad.
It won't run the program because the code is not correct, the same way a C compiler will refuse to compile a missing semicolon. If different indentation changes the meaning of a program from wipe the disk if condition true to wiping regardless of condition, that's a pretty bad change, so the interpreter rightly refuses to run incorrect programs.
I use ahk to send the clipboard as typed letters when dealing with certain vms or remote access or weird webpages and normal paste doesn't work. The shortcut is ctrl+b
I'd like to ask the AHK programmers here if anyone can figure out how to do the macOS's CMD+` and CMD+SHIFT+` to alternate between windows of the same App in Windows while ignoring any minimized window.
I managed to coerce chat GPT to do a working version for the `Last Window`, but it simply cannot do a working forward version.
```
!+`:: ; Last window
WinGet, ActiveProcessName, ProcessName, A
WinGet, windows, List, ahk_exe %ActiveProcessName%
Loop, % windows
{
thisID := windows%A_Index%
WinGet, thisWindowState, MinMax, ahk_id %thisID%
if (thisWindowState = -1)
continue ; Skip if window is minimized
lastWindow := thisID
}
if (lastWindow)
{
WinActivate, ahk_id %lastWindow%
}
return
I've used GroupAdd[1] and GroupActivate to alternate between windows of the same app but it doesn't ignore minimised windows. Maybe you can ignore minimised when adding to the GroupAdd list some how.
If you like macOS keyboard shortcuts, I recommend you checkout Kinto go Windows and Linux. On Windows, Kinto used AHK
https://kinto.sh
However, at least when I set it up Kinto did not provide switching windows in this fashion. Here is the script I use. This includes some related functionality to make the handling of windows more Mac-like
^!`::
WinGetClass, class, A
WinGet, id, list, ahk_class %class%
Loop, %id%
{
this_id := id%A_Index%
WinActivate, ahk_id %this_id%
; MsgBox, The active window's this_id is "%this_id%".
}
return
; MINIMIZE ALL WINDOWS OF THE CURRENT APPLICATION
^!m::
WinGetClass, class, A
WinGet, id, list, ahk_class %class%
Loop, %id%
{
this_id := id%A_Index%
WinMinimize, ahk_id %this_id%
}
return
; CYCLE ALL WINDOWS OF CURRENT APPLICATION
; Pull bottom window to the top, and force it to display
^`::
; need Process and Class to restrict to current application
; most apps have unquie window classes, but Chromium based apps
; share their primary window class. Thus Google Chrome, VS Code and
; Electron based apps all looked the same using only `class`
WinGet, Active_ID, ID, A
WinGet, Active_Process, ProcessName, ahk_id %Active_ID%
WinGetClass, class, A
WinGet, id, list, ahk_class %class% ahk_exe %Active_Process%
lastItem := id%id0%
lastItemId := id%lastItem%
WinActivate, ahk_id %lastItemId%
WinSet, Top,, ahk_id %lastItemId%
Winset, AlwaysOnTop, On
Winset, AlwaysOnTop, Off
return
; CLOSE CURRENT WINDOW AND ACTIVATE NEXT WINDOW OF CURRENT APP
; similar to the CYLCE ALL WINDOWS OF CURRENT APP, but closes the
; current window.
;
; Because some Apps have Tabs that are closed via the same `^w` shortcut,
; we only switch to the next active window if the current window no longer
; exists after sending `^w`
;
; RATIONAL: This makes the Application Context a little more like macOS
; where closing windows leaves you in the current application, and not
; a random window that is the next in the stack.
$^w::
; need Process and Class to restrict to current application
; most apps have unquie window classes, but Chromium based apps
; share their primary window class. Thus Google Chrome, VS Code and
; Electron based apps all looked the same using only `class`
WinGet, Active_ID, ID, A
WinGet, Active_Process, ProcessName, ahk_id %Active_ID%
WinGetClass, class, A
WinGet, id, list, ahk_class %class% ahk_exe %Active_Process%
lastItem := id%id0%
lastItemId := id%lastItem%
Send ^w
Sleep 50
WinGet, Current_ID, ID, A
If (Current_ID != Active_ID) {
WinActivate, ahk_id %lastItemId%
WinSet, Top,, ahk_id %lastItemId%
Winset, AlwaysOnTop, On
Winset, AlwaysOnTop, Off
}
return
An absolute must-have for me is an AHK script I use to clear the clipboard 15 seconds after something is copied to it. I developed it after a colleague pasted in chat, "Let's call it $xxxK and call it a fair deal" (with actual numbers) :|
I once used it on a citrix app. Can't use some of its functions that "find" controls on a form, so I set it to resize the window to a consistent size everytime and then execute its clicks at the right x,y coordinates.
I learned that you could click buttons before they were even drawn on the screen.
... and so on with all the German letters and currency symbol.
As a bonus, <Caps> on its own is mapped to "find" (Ctrl + F)
and <Caps> + f runs Send "{Space}datemodified:this year -kind:=folder", for when you have a lot of historical documents and want to get quickly on with the most recent using Microsoft's bafflingly stupid search operators. (Caveat, you have to switch to "last year" in January.)
Not sure if AutoHotKey is the tool for this, but, I am looking for a functionality such that, when I get a ping from MS Teams (say), I want some other system in my home network to notify me of it - perhaps a notification in my android phone?
It does, but it is extremely limited. The StreamDeck plugin covers essentially the entire (local) API surface. From what I glanced, it might even have been created for the Stream Deck plugin.
For everything else, you can either parse a log (have fun!) or ask your AD admin to create credentials so you can use graph API after an OIDC handshake (also have fun!)
I used to use an Ann Pro 2 keyboard. By default, h, j, k, l could be used as arrow keys when fn was held down. The fn keys also remapped '[]' to 'home' and 'end', ";'" to pgup, pgdown, and '/' to delete. It also had this feature where the caps lock key acted as a fn key when held down. I very quickly got used to holding the caps lock key with my left pinky to access all the keys I needed with my right hand. I became much more productive on this little 60% keyboard than on any full-sized one as I never had to move my fingers from the home row.
I've now switched to a qmk compatible Keychron V2 (65%) keyboard and remapped the keys exactly the same way. I'm very tempted to go back to a more compact 60% since I literally never use the arrow keys.
When I use my laptop on the go, AHK to the rescue. I found a script[0] that does almost the same thing, unfortunately, it fails when I use more than one modifier with the arrow keys. For example: shift + ctrl + left arrow to select one word to the left, which is shift + ctrl + caps lock + h in my case, doesn't work.
I remember comparing AutoIt and AutoHotKey to pick which one to learn. The community being really open and seemingly twice as large at the time was why I selected AHK. Shame about the language syntax though, I still fight with it. But it is very powerful.
The syntax was one of the main reasons I chose AutoIt. For some reason I cannot stand the AHK syntax. For me personally it is hard to bring structure to an AHK code.
AHK is tricky enough, but I have a hard time finding available key sequences. For example, is there some way to search your system to see if anything is hooking ctrl-7?
Alternatively, do you have a favorite key sequence pattern that usually works? The linked scripts seem to use stuff like “;.” which is pretty clever. Semicolon isn’t usually followed by anything except space.
I haven’t used AHK in years since moving to Mac, but I used to have that same issue. I may have spent more time finding just the right key chord than I did actually using AHK. It’s hard to find something ergonomic and easy to remember that isn’t already used by any of my regular programs.
It would be nice if keyboards had an equivalent of 127.0.0.0/8 where you know nobody else is listening for a key combination in that range.
BetterTouchTool has a different approach, it's not a programming language per se, but lets you write JavaScript or AppleScript code to achieve anything you can do with AutoHotkey, and more. If BTT were available for Windows, I'd never touch AHK again.
Yes, AHK is "lower level" regarding input tracking, so in KM left vs right modifiers aren't properly supported (though there are hackarounds that can make it work)
Then the sripting language is easier for batch editing and various permutations with proper functions and variables (though again KM can be partially hacked around to make it easier)
Back when I worked at an IT company, I created a very simple AHK script where pressing Ctrl + Alt + V would type in the contents of the clipboard, rather than paste it. We were constantly remoting into servers that required tediously typing strong passwords at the Windows login prompt, and this workaround allowed us to "paste" them directly into the password field.
Nowadays I'm on macOS and I use BetterTouchTool and karabiner-elements to handle all kinds of miniature efficiency patches, and they make a huge difference for me. BTT in particular allows for a limitless amount of system control, such as triggering context menu actions, running AppleScript, or even showing/hiding a floating WebView of your own HTML document. I've barely scratched the surface.
AutoHotkey is what made me fall love programming after disliking it after getting my degree. After switching to a macbook, AutoHotkey is probably what I miss most from being on Windows. It really has it all.
I'm using AutoHotkey as my own custom IME, allowing me to type special characters, navigate in text and switch between applications without leaving the middle 3 rows of the keyboard: https://github.com/MatejKafka/KeyboardRemap/
The README contains layout diagrams if anyone's interested.
My most used one is to map Right Ctrl+V to paste by actually typing what's on the clipboard instead of pasting allowing pasting in places where you may not have it - e.g. login boxes on certain KVM controllers.
>^v::
SetKeyDelay, 10, 10
SendRaw %clipboard%
Return
; this version types it with a larger delay to account for latency
>^+v::
SetKeyDelay 500, 10
SendRaw %clipboard%
Return
I love AHK. I have Ctrl-` pop up Windows Terminal, but only from programs that don't already have an integrated terminal; I have Ctrl-Alt-Space for a window to stay always-on-top; and I have an auto-clicker that's integrated with MouseKeys to use its enabled state and right-click-vs-left-click state and which cancels itself if the mouse is moved at all.
That's strange. From my point of view it you get lots of value in the beginning but there is some kind of cap beyond, that it is hard to get over.
I think AHK has really easy onboarding, meaning you can get tremendous low-hanging benefits out of it minute after installation -- you open the help, do your first `::btw::by the way` hostring, map reloading the script to `^+!r::reload` and from this point on you iterate quite rapidly, progressively fixing your easily fixable pains -- but sooner or later, after reaching some level of complexity, things begin to get hairy, not worth the effort or even impossible.
But as as say, there is vast amount of simple shenanigans you can make with basic AKH functionality, most of them you can even make on your own just with the help file.
For such simple and repetitive tasks I would suggest giving TinyTasks a try (https://www.tinytask.net/). There's no coding, you just press record do what ever needs to be done, stop recording, select how many times to repeat and play!
`::
IfWinActive Untitled - Notepad
WinClose
else
IfWinActive *Untitled - Notepad
WinClose
else
IfWinExist Untitled - Notepad
WinActivate
else
IfWinExist *Untitled - Notepad
WinActivate
else
Run Notepad
return