[HN Gopher] Learn AutoHotKey by stealing my scripts
       ___________________________________________________________________
        
       Learn AutoHotKey by stealing my scripts
        
       Author : Tomte
       Score  : 296 points
       Date   : 2023-08-22 03:20 UTC (19 hours ago)
        
 (HTM) web link (www.hillelwayne.com)
 (TXT) w3m dump (www.hillelwayne.com)
        
       | FrenchTouch42 wrote:
       | Comes in handy for opening Hearthstone packs so you don't need to
       | continuously press space.
        
         | LoveMortuus wrote:
         | 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!
        
       | vijucat wrote:
       | 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) :|
       | 
       | Should be mandatory at law firms, for example.
        
       | dattiimo wrote:
       | This AutoHotKey script was a game changer for me. It maps Ctrl +
       | Shift + V to paste without formatting.                   ;; Text-
       | only paste from ClipBoard         ;;
       | (https://autohotkey.com/board/topic/10412-paste-plain-text-and-
       | copycut/)         ;; ctrl + shit + v         ^+v::
       | Clip0 = %ClipBoardAll%             ClipBoard = %ClipBoard%
       | ; Convert to text             Send ^v                       ; For
       | best compatibility: SendPlay             Sleep 150
       | ; Don't change clipboard while it is pasted! (Sleep > 0)
       | ClipBoard = %Clip0%           ; Restore original ClipBoard
       | VarSetCapacity(Clip0, 0)      ; Free memory         Return
       | 
       | [Edit: tried to fix formatting]
        
         | [deleted]
        
         | inanutshellus wrote:
         | ctrl-shift-v is so nice. it should be an OS-standard keyboard
         | shortcut for clipboards.
         | 
         | would also love to get a mult-value clipboard (e.g. my last 5
         | clips) but... that's asking a lot i guess. ;-)
        
           | djbusby wrote:
           | Works out of the box on Xfce.
        
           | wrboyce wrote:
           | 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.
        
           | inafewwords wrote:
           | 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
        
             | okrad wrote:
             | Slightly more cumbersome but try Option-Cmd-Shift-v
        
             | w0m wrote:
             | On Mac, I'd always open up alfred, Paste, then copy it
             | again to strip formatting. Pita but it worked and was rote
             | after years of use.
             | 
             | cmd-space, cmd-v,cmd-a,cmd-x (buffer is now stripped)
        
           | function_seven wrote:
           | Use WIN+V instead of CTRL+V to get a clipboard history pop-up
           | in Windows 10.
           | 
           | https://support.microsoft.com/en-us/windows/clipboard-in-
           | win...
        
             | pnutjam wrote:
             | woah... This works in KDE too on linux.
        
             | w0m wrote:
             | Just _why_ can 't you search it? I used Alfred religiously
             | on OSX for this functionality; and it's _almost_ there.
        
               | function_seven wrote:
               | 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.
        
               | riezebos wrote:
               | In case you are not aware: https://ditto-
               | cp.sourceforge.io/
        
             | aimor wrote:
             | Wow, I feel like it's time to bring back the "Welcome to
             | Windows" tips at login.
             | 
             | ..is there a way to bring that back?
        
         | mailund wrote:
         | 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.
        
           | innocenat wrote:
           | Copy image from one place to another. Copy entire powerpoint
           | slide between presentation. Copy table from web to word.
        
             | nixass wrote:
             | How many times in a day you do that versus pasting with no
             | formatting?
        
               | stronglikedan wrote:
               | Exceptionally more, personally.
        
               | w0m wrote:
               | 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.
        
               | pynappo wrote:
               | 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.
        
         | benhurmarcel wrote:
         | For the record, it's also available without AutoHotKey, using
         | Powertoys [1] or PureText [2]. Very useful.
         | 
         | [1] https://learn.microsoft.com/en-us/windows/powertoys/
         | 
         | [2] https://stevemiller.net/puretext/
        
           | screye wrote:
           | Can't understand why Powertoys don't come standard in Windows
           | 11. They're too useful and too polished to be an optional
           | add-on.
        
             | jcotton42 wrote:
             | 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.
        
           | dattiimo wrote:
           | 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.
        
           | perennialmind wrote:
           | With AutoHotKey you can escalate to sending as-if-by-
           | keyboard, for those frustrating scenarios where clipboard
           | paste is ignored.                 SendInput {Raw}%ClipBoard%`
        
       | scottfr wrote:
       | 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.
       | 
       | [0] https://blaze.today
       | 
       | [1] We're currently beta testing Mac and Windows desktop
       | versions.
       | 
       | [2] https://blaze.today/guides/forms/
       | 
       | [3] https://blaze.today/formulas/reference/
       | 
       | [4] https://blaze.today/datablaze/docs/bsql/
        
       | iamjason89 wrote:
       | 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.
        
         | inafewwords wrote:
         | 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
        
           | PennRobotics wrote:
           | from the V1 docs,
           | 
           | To avoid [infinite loops] add the $ prefix to the hotkey
           | definition (e.g. $^c::) so that the hotkey cannot be
           | triggered by the Send command.
           | 
           | or a very restrictive #MaxHotkeysPerInterval
        
       | dave7 wrote:
       | 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
        
       | FranklinMaillot wrote:
       | 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.
       | 
       | [0] https://github.com/AlexP11223/hjkl-
       | keybindings/blob/master/w...
        
       | Wolfenstein98k wrote:
       | 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.
        
         | criddell wrote:
         | 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.
        
         | lazylion2 wrote:
         | 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
        
         | emi2k01 wrote:
         | I find it hard too and I've plenty of experience programming.
         | 
         | The alien syntax, the incompatibilities between versions, the
         | outdated information on the internet made it difficult to
         | learn.
         | 
         | I'd recommend to just use python with a library like pyautogui
         | and similar.
        
         | mackrevinack wrote:
         | 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
        
       | slig wrote:
       | 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
       | 
       | ```
        
         | dattiimo wrote:
         | 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.
         | 
         | [1] https://www.autohotkey.com/docs/v1/lib/GroupAdd.htm
        
           | slig wrote:
           | Thanks! I was going to ask you on your comment, thanks!
        
         | leejoramo wrote:
         | 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
         | 
         | ```
         | 
         | ; BRING FORWARD ALL WINDOWS OF THE CURRENT APPLICATION ; This
         | is a generalized version of ;
         | https://superuser.com/questions/113162/bring-to-front-all-wi...
         | ^!`::             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
         | 
         | ```
        
           | slig wrote:
           | Thank you so much!
        
       | account-5 wrote:
       | My favourite AHK story ever:
       | https://old.reddit.com/r/antiwork/comments/qstsdp/my_5year_g...
        
       | devindotcom wrote:
       | 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!
       | 
       | `::
       | 
       | IfWinActive Untitled - Notepad
       | 
       | WinClose
       | 
       | else
       | 
       | IfWinActive *Untitled - Notepad
       | 
       | WinClose
       | 
       | else
       | 
       | IfWinExist Untitled - Notepad
       | 
       | WinActivate
       | 
       | else
       | 
       | IfWinExist *Untitled - Notepad
       | 
       | WinActivate
       | 
       | else
       | 
       | Run Notepad
       | 
       | return
        
         | Willwhatley wrote:
         | ; I call this "Tilde opens Notepad" after yours, devindotcom.
         | 
         | ; It is made in Autohotkey2.                 `::  ; Tilde key
         | {       If WinActive("Untitled - Notepad") or
         | WinActive("*Untitled - Notepad")        WinClose       else
         | If WinExist("Untitled - Notepad") or WinExist("*Untitled -
         | Notepad")        WinActivate       else        Run "Notepad"
         | }
        
         | LelouBil wrote:
         | Wouldn't notepad++ be better because of the auto save ?
         | 
         | I think auto saving of unsaved documents is one of it's best
         | features
        
           | TuringTest wrote:
           | Notepad++ may be extremely slow to open if you have a
           | previous tab with a huge file, like a log or a xml data dump.
           | 
           | That would defeat the point of having the notetaking window
           | open instantly.
        
         | mackrevinack wrote:
         | that's a good one
         | 
         | fyi, if you use the WinActive() or WinExist() functions you can
         | combine different titles
         | 
         | If WinActive("Untitled - Notepad ahk_class Notepad") or
         | WinActive("*Untitled - Notepad ahk_class Notepad")
         | 
         | maybe you don't have to put in the "ahk_class Notepad" bit, its
         | been a while since i used ahk!
        
         | myfonj wrote:
         | 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:                   ; Toggle <...>
         | window using Ctrl + Shift + Win + <key>          ^+#<key>::
         | _bckTMM := A_TitleMatchMode         _bckDHW :=
         | A_DetectHiddenWindows         SetTitleMatchMode, 2
         | DetectHiddenWindows, On         ifWinExist, <... window title
         | fragment>         {           ifWinActive           {
         | send, !{escape}           }           else           {
         | WinActivate           }         }         else         {
         | run, <... launcher>         }         DetectHiddenWindows,
         | %_bckDHW%         SetTitleMatchMode, %_bckTMM%         return
         | 
         | 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`.
        
           | larschdk wrote:
           | My similar solution that I use for
           | Outlook/Teams/TotalCommander/more: https://github.com/larsch/
           | AutoHotkeyScripts/blob/main/Launch...
           | 
           | 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.
        
             | diogotito wrote:
             | I also wrote my AHK functions to have hotkeys to cycle
             | through (or toggle) windows from an application! Here:
             | https://github.com/diogotito/autohotkey-
             | scripts/blob/desktop...
             | 
             | and here's where I declare most of my hotkeys:
             | https://github.com/diogotito/autohotkey-
             | scripts/blob/desktop...
             | 
             | 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
             | _N_ th application
             | 
             | - Ctrl+Win+<N> to launch, toggle or _cycle_ through the
             | windows from the _N_ th 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!
        
               | myfonj wrote:
               | 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                   start "" "C:\...\7+ Taskbar
               | Numberer.exe" -v2 -hidewnd
               | 
               | 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.co
               | m/myfonj/62b4e0d393f4a97df5e9904df5e77...
               | 
               | (Sadly, none of those will probably ever work outside
               | Windows 10 (?))
        
           | ghusbands wrote:
           | > flip back to previous window "toggle", super useful but
           | (for me) long time forgotten native Windows hotkey is _`Alt +
           | Windows key`_
           | 
           | Pressing alt + win key does nothing for me on this Windows 10
           | machine.
        
             | myfonj wrote:
             | 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.)
        
         | [deleted]
        
         | sh4rks wrote:
         | 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.
        
           | Oranguru wrote:
           | 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.
        
             | basiskarten wrote:
             | Very well said. It also feels really good to get rid of
             | small things that annoy you every day by creating your own
             | solutions, cf.:
             | 
             | https://www.joelonsoftware.com/2000/04/10/controlling-
             | your-e...
        
           | hwayne wrote:
           | That's one of the things I do in the codebase, though more
           | configurable (so you can have multiple note categories). The
           | change is something like                   Run (A_WorkingDir
           | . "\Config\Notes\" . this.NoteType . ".txt")
        
       | pydave wrote:
       | 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.
       | 
       | [1]:
       | https://github.com/idbrii/daveconfig/blob/main/win/autohotke...
       | [2]: https://pypi.org/project/ahk/
        
         | eviks wrote:
         | Indeed, that's the biggest issue with AHK, though v2 helps a
         | lot in this regard.
         | 
         | Dreams of a universal hotkey listener you could use in any
         | language via some wasm plugin magic?
        
         | ramenbytes wrote:
         | 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.
        
           | pmontra wrote:
           | 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
           | 
           | :-)
        
           | TOGoS wrote:
           | It's always time to sit down and write a lisp DSL. That
           | compiles itself to AutoHotKey scripts so you can compile
           | while you key.
           | 
           | (I am in the process of doing this inside OpenSCAD.)
        
         | poisonborz wrote:
         | 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.
        
           | eviks wrote:
           | 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)
        
           | hwayne wrote:
           | 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.
        
           | layer8 wrote:
           | 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.
        
           | wruza wrote:
           | 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.
        
             | hwayne wrote:
             | Couple of ways to tell
             | 
             | 1. Do your multiline hotkeys have `Return` in them, or are
             | they in braces?
             | 
             | 2. Do you write `Send Foo` or `Send "Foo"`?
             | 
             | If you're doing the former, then I really recommend
             | upgrading to v2, it makes a huge difference.
        
               | wruza wrote:
               | I think the former. Thanks, I'll look into it!
        
       | gnopgnip wrote:
       | 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
       | 
       | ^+b::SendRaw %clipboard%
        
       | dattiimo wrote:
       | 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.
       | 
       | It makes switching between apps so much faster.
        
         | anjanb wrote:
         | can you share your script please ?
        
           | dattiimo wrote:
           | 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.
        
           | hwayne wrote:
           | That's one of the things I have in the project! At least the
           | window switching. Not the dynamic window selection and "edit
           | mode" though.
           | https://github.com/hwayne/autohotkey-
           | scripts/blob/main/Lib/WindowSwitching.ahk
        
       | millzlane wrote:
       | One of the best ones I used was one that would switch the audio
       | output source between my headset and speakers using a hot key.
        
         | fuzztester wrote:
         | > - turn a Youtube "shorts" url in to it's regular Youtube page
         | "watch" version via URL manipulation
         | 
         | Interesting. What is the reason for doing that?
        
       | criddell wrote:
       | 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.
        
         | onionisafruit wrote:
         | 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.
        
       | sireat wrote:
       | 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.
        
         | eviks wrote:
         | there is an effort to rewrite AHK in C# and support other OS
         | https://www.autohotkey.com/boards/viewtopic.php?f=80&t=77248
        
         | simula67 wrote:
         | 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.
        
         | hwayne wrote:
         | 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!
        
         | vxNsr wrote:
         | 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.
        
       | ra1n wrote:
       | 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 :)
       | 
       | [1]: https://github.com/microsoft/PowerToys [2]:
       | https://github.com/susam/uncap [3]:
       | https://stackoverflow.com/questions/38558376/how-to-map-caps...
        
         | sbt567 wrote:
         | Kanata[0] is amazing. It support both Linux and Windows. But
         | I'm yet to try it on windows because my majority work is on
         | linux.
         | 
         | [0] https://github.com/jtroo/kanata
        
         | rgoulter wrote:
         | > I have swapped Caps Lock and Escape on my Linux personal
         | laptop and I have grown used to it.
         | 
         | I'd also suggest "home row modifier keys" (or "home row mods").
         | 
         | The idea is to have the key behave the same when tapped, but
         | differently if held. (e.g.
         | https://github.com/evilC/TapHoldManager implements this for
         | AHK)
         | 
         | 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.
        
         | wellthisisgreat wrote:
         | Can't give an AHK answer but what about Sharpkeys?
        
         | nickjj wrote:
         | I've been using AHK to swap these keys for years, this script
         | works (it's different than your linked StackOverflow answers):
         | CapsLock::Esc         Esc::CapsLock
         | 
         | I wrote about a number of other AHK quick wins, such as
         | launching programs with global hotkeys here:
         | https://nickjanetakis.com/blog/remap-and-set-global-hotkeys-...
        
         | sorz wrote:
         | 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.
         | 
         | [1] https://superuser.com/questions/550679/where-can-i-find-
         | wind...
        
         | hielke wrote:
         | I was stuck on the same struggles, but eventually managed to
         | bodge something together:
         | 
         | https://github.com/hwalinga/dotfiles/blob/master/CapsLockCtr...
         | 
         | It also implements the double feature functionality of CapsLock
         | that now functions as Ctrl when pressed with another key, and
         | just Esc when tapped.
        
       | [deleted]
        
       | deostroll wrote:
       | 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?
       | 
       | Anyway we can achieve this?
        
         | ChoGGi wrote:
         | I believe you can use ahk to monitor colour changes?
        
         | RobertSponge wrote:
         | Doesn't ms teams have API? I have elgato stream deck and it
         | talks to the local client via official client API.
        
           | [deleted]
        
           | asmor wrote:
           | 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.
           | 
           | https://support.microsoft.com/en-us/office/connect-to-
           | third-...
           | 
           | 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!)
        
         | ThrowawayTestr wrote:
         | Check out if this then that (iftt)
        
         | mackrevinack wrote:
         | sounds like something that would be better suited to ifttt or
         | zapier
        
       | ajonit wrote:
       | AutoHotKey is great.
       | 
       | Few years back, I made a video and published a free downloadable
       | AHK template.
       | 
       | https://www.learnqtp.com/get-productive-with-automation-auto...
        
       | LoveMortuus wrote:
       | AutoHotKey is amazing!
       | 
       | 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!
        
         | trinovantes wrote:
         | I remember the old days when I could automate woodcutting in
         | runescape
         | 
         | Sadly a lot of games nowadays have (shitty) anti cheat systems
         | that just ban you if you have the process running or have the
         | program installed
        
         | infogulch wrote:
         | > 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
        
         | quikoa wrote:
         | If you don't mind sharing which MMO are you playing? It sounds
         | exciting being able to automate that much! :)
        
           | LoveMortuus wrote:
           | 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.
        
         | isaacfrond wrote:
         | AutoHotKey is amazing! for cheating! Right, noted.
        
           | Prickle wrote:
           | Some MMOs you really need automated scripts to hit those 0.1s
           | timers. And the majority are time wasters and not very fun.
           | 
           | The game should incentivize you to play and enjoy, not farm
           | activity #399
           | 
           | There are also legitimate accessibility issues this can
           | resolve, but would be considered cheating in many games.
        
           | LoveMortuus wrote:
           | 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.
        
           | ramblerman wrote:
           | Automating a repetitive task in a low stakes environment, oh
           | no.
           | 
           | that's probably the definition of how most programmers got
           | started. Get off your high horse
        
           | brokenmachine wrote:
           | OP is just playing a different game to the other players.
           | 
           | If the game is boring enough that it can be played by an ahk
           | script, then it probably isn't the most interesting game in
           | the first place.
           | 
           | The ahk game sounds like more fun to me.
        
             | lfkdev wrote:
             | 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
        
               | computerfriend wrote:
               | Other players can write automation too.
        
               | csydas wrote:
               | 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
        
               | Tarsul wrote:
               | 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...
        
       | PeterStuer wrote:
       | I read AutoHotKey is a real lifesaver ... in Path of Exile.
        
         | jtriangle wrote:
         | Also works great for automating userspace applications that
         | you're forced to use.
        
           | Scoundreller wrote:
           | 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.
        
       | jerrygoyal wrote:
       | here's my list of top AHK scripts:
       | https://gourav.io/blog/autohotkey-scripts-windows
        
       | qwertox wrote:
       | AHK is one of the apps which locks me into using Windows. I use
       | it to add characters like aouss and aoun 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.
        
         | otoburb wrote:
         | >> _AHK is one of the apps which locks me into using Windows._
         | 
         | Hammerspoon[1] seems to be the best option for macOS.
         | 
         | [1] https://www.hammerspoon.org/
        
           | pmoriarty wrote:
           | I prefer using Keyboard Maestro[1] for this, which does a lot
           | more than just allow you to remap the keyboard.
           | 
           | [1] - https://en.m.wikipedia.org/wiki/Keyboard_Maestro
        
             | mastercheif wrote:
             | 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.
             | 
             | Is there anything like KM for Windows??
        
         | OsrsNeedsf2P wrote:
         | I use AutoKey on Linux. It's less powerful than AHK but uses
         | native Python which is nice: https://github.com/autokey/autokey
        
           | yomlica8 wrote:
           | How does it compare to xdotool?
        
         | wink wrote:
         | 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.
        
         | PennRobotics wrote:
         | 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.
        
           | qwertox wrote:
           | I actually have an old Korg nanoKontrol, but when I tested it
           | with Python I had issues. I think it always stopped working
           | after a couple of hours.
        
           | BTWritesCode wrote:
           | I've done this.
           | 
           | 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.
           | 
           | [1] https://docs.qmk.fm/#/feature_midi
           | 
           | [2] https://github.com/dannywarren/AutoHotkey-Midi
        
         | mackrevinack wrote:
         | 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
        
           | criddell wrote:
           | > you need multiple programs on Linux
           | 
           | Why is that? Is there something about Linux that makes it
           | difficult to do all the stuff AHK can do on Windows?
        
             | pie_flavor wrote:
             | 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.
        
         | dttyde wrote:
         | I've had some good experiences with using Luamacros to
         | intercept a second keyboard and forward the keypresses to
         | autohotkey like this:
         | https://miquelvir.medium.com/secondkeyboard-1c39e52e023b
         | 
         | Apparently there is also this:
         | https://github.com/evilC/AutoHotInterception
        
           | jabroni_salad wrote:
           | 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.
        
       | yogurthewise wrote:
       | AHK has been a life saver for me when it comes to alpha/beta
       | games that haven't yet implemented a key binding system!
        
       | 3164 wrote:
       | [dead]
        
       | ohlookcake wrote:
       | This looks great. What's the closest/best Mac equivalent?
        
         | RajSinghLA wrote:
         | Raycast
        
         | pahund wrote:
         | 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.
        
         | eviks wrote:
         | Karabiner Elements is very powerful and low level (so struggles
         | with higher-level concepts like inserting a symbol or showing
         | some GUI)
         | 
         | Keyboard Maestro has a great interactive UI, and also built-in
         | UI panels that are also great as "cheat sheets"
         | 
         | BetterTouchTool is superb in touchpad/mouse control (but can
         | also do shortctuts)
        
         | krackers wrote:
         | applescript + hammerspoon
        
         | lycopodiopsida wrote:
         | The closest equivalent is maybe hammerspoon. But the automation
         | ecosystem on mac is much bigger:
         | 
         | - KeyboardMaestro is pretty equal, but is paid and takes a more
         | gui-centric approach to automation building. Definitely more
         | user-friendly.
         | 
         | - BetterTouchTool has a lot of intersecting features, but is
         | more catered to gui scripting and gestures.
         | 
         | - Alfred has introduced automation scripts and triggers.
         | 
         | - There is also Shortcuts, which is sometimes quite odd to use
         | and limited, but has the advantage of Workflows working on mac
         | and iOS/iPadOS.
        
         | panic wrote:
         | There's nothing exactly like it, but I use Keyboard Maestro for
         | macros and such.
        
           | magarnicle wrote:
           | Is there anything AHK can do that Keyboard Maestro cannot?
        
             | [deleted]
        
             | eviks wrote:
             | 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)
        
             | Loocid wrote:
             | Being free is a big one.
        
       | larschdk wrote:
       | Great stuff. I use AutoHotKey all the time too:                 -
       | 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 (aeoaudeg and some emojis)       - Media & Volume
       | shortcuts (start/stop/next, volume up, volume down)
        
         | aemoron wrote:
         | 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!
        
           | larschdk wrote:
           | https://github.com/larsch/AutoHotkeyScripts
        
             | aemoron wrote:
             | Appreciate it!
        
           | jaclaz wrote:
           | Cannot say if useful, but if you need to insert/copy paste
           | text (and modifiers) there is a tool written in AHK that is
           | very handy:
           | 
           | https://lintalist.github.io/
        
       | gwill wrote:
       | I love AutoHotkey, but it doesn't pass security scans at my place
       | of work. is there an alternative for running macro scripts?
        
         | a2tech wrote:
         | Even if you compile the script to a binary? I've used them at
         | some pretty security minded places and never got nailed for it
        
       | dansalvato wrote:
       | 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.
        
       | villgax wrote:
       | [flagged]
        
       | animal531 wrote:
       | 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.
        
       | trojan13 wrote:
       | I always preferred AutoIt to AutoHotKey, but AutoIt never got any
       | updates and the community is slowly dying while AutoHotKey seems
       | to be doing great.
        
         | yomlica8 wrote:
         | 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.
        
           | trojan13 wrote:
           | 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.
        
       | PennRobotics wrote:
       | AHK is great for setting up a quicker compose key and keeping a
       | frictionless wheel mouse like the MX Master from zooming when you
       | press <Ctrl>.                   ^WheelDown::         {
       | return         }         ^WheelUp::         {           return
       | }
       | 
       | (this possibly needs A_MaxHotkeysPerInterval := 2000 )
       | 
       | -----
       | 
       | <Caps> + a = a.
       | 
       | <Caps> + <Shift> + a = A.
       | 
       | ... 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.)
        
       | pie_flavor wrote:
       | 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.
        
         | 0-_-0 wrote:
         | Check out 'quake mode' of Windows Terminal
        
       | wellthisisgreat wrote:
       | AHK and powertoys are the two programs that make Windows
       | tolerable.
       | 
       | I haven't yet played with AHK 2 and ChatGPT, but since she has a
       | cutoff at 2021, she may not know be well versed in AHK 2.0
        
         | bobsmooth wrote:
         | ChatGPT is not. It'll say it knows AHK 2.0 but the code it
         | generates is non-functional despite looking correct.
        
       | hackernudes wrote:
       | Here is my collection of AutoHotKey v2 scripts:
       | https://github.com/EBADBEEF/ahkv2-scripts
       | 
       | 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.
        
       | hateful wrote:
       | 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
        
       | 2Gkashmiri wrote:
       | 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.
        
         | BanazirGalbasi wrote:
         | 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.
        
           | 2Gkashmiri wrote:
           | its like trying to learn to drive while the car is actively
           | trying to not let you drive. you can do it but its not fun.
           | 
           | i want to do a loop, i dont want to learn to be forced to
           | understand indentation. that kills the enthusiasm imo.
        
             | zo1 wrote:
             | 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.
        
               | 2Gkashmiri wrote:
               | i have used notepad for ahk. that's the preferred IDE
        
               | hwayne wrote:
               | Use VSCode with the AHK extension, it's a million times
               | better than notepad for AHK
        
             | wruza wrote:
             | 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.
        
             | pmontra wrote:
             | 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.
        
             | Loocid wrote:
             | Is it really that different to being forced to understand
             | scoping with curly braces in other languages?
        
               | 2Gkashmiri wrote:
               | 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.
        
           | xchkr1337 wrote:
           | 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.
        
             | gattilorenz wrote:
             | Does it? You can perfectly use tabs, just dont mix them up
             | (also a source of Python pains)
        
         | e63f67dd-065b wrote:
         | 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.
        
       | omnibrain wrote:
       | 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.
        
         | basiskarten wrote:
         | Sounds like a really cool project. Did you take any pictures of
         | the box? Also congrats on getting married!
        
       | nullandvoid wrote:
       | One of my fondest AHK memories was back when I created a bot for
       | a runescape private server when I was younger.
       | 
       | It clicked on pixels of a certain character in game to thieve an
       | NPC, and could detect full inventory, bank and go again.
        
       ___________________________________________________________________
       (page generated 2023-08-22 23:02 UTC)