Hillel Profile picture
May 23 15 tweets 5 min read
Some AutoHotKey tips:

1. Don't shirk on good practice. Most AHK code in the wild is jank because most AHK coders aren't software developers, they don't know any better. But you do, so use functions, proper data structures, abstractions, etc and the process will be a lot nicer.
2. You can use window groups to restrict a hotkey to just web browsers (via IfWinActive) or make a hotkey that alt-tabs through a specific set of programs (via GroupActivate)

autohotkey.com/docs/commands/…
3. The #If directive takes expressions. I have Numpad- flip a `subscript_mode` flag and two sets of hotkeys that are conditionally activate. That way I can use the same keycombo for ¹ and ₁

autohotkey.com/docs/commands/…
4. Find ways to group similar operations under the same root hotkeys. My favorite trick is using Input to make hotkeys that are two keypresses *in sequence*. So `^+d` could be the "open file" root, and the letter you press next determines *which* file

autohotkey.com/docs/commands/…
5. If you're doing the Input trick and storing options in an object map, be aware that dicts are case insensitive and you'll have problems if both `a` and `A` are in the dict. I built a weird workaround, you should probably just use a COM object docs.microsoft.com/en-us/office/v…
6. Also you can't index on strings, you have to use SubStr, but AHK will silently fail without giving an error if you try to index, which is hair-pullingly hard to figure out
7. `^d` is the hotkey "ctrl+d". `>^d` is the same, but ONLY when right ctrl is pressed. I use this to only place hotkeys on the right modifiers so I can use the left modifiers for the system default hotkeys

autohotkey.com/docs/Hotkeys.h…
8. `#!.::Reload` makes alt+win+. reload the current AHK script. Makes iterative development real easy

autohotkey.com/docs/commands/…
9. AHK is godawful at lots of things like database access, datetime processing, and string munging. If you have to do that, you're better off using RunWait to call an auxiliary program and doing the calculations there

autohotkey.com/docs/commands/…
Here's a godawful example of shelling to python

timeshim := A_WorkingDir . "\Lib\Aux-Scripts\timeshim.py"
cliptime := clipboard
cmd := "pythonw.exe " . timeshim . " --date=""" . cliptime . """ | clip"
RunWait, %ComSpec% /c "%cmd%",,Hide
out := clipboard
return out
10. You can create custom TrayTips and finally make that UI feature useful to you once in your goddamn life

autohotkey.com/docs/commands/…
11. Most remote presentation clickers work by sending keyboard codes to the computer, you can use AHK to make them into remote controls for any app. I once had my clicker restart songs in Spotify to practice a dance thing
12. Most programs don't let you remap keyboard shortcuts to mouse buttons like ctrl+middleclick or MouseWheelLeft, but you can add mouse shortcuts in AHK! eg

#IfWinActive, ahk_exe audacity.exe
MButton::Send ^l
13. AHK comes with a bunch of special variables, like A_ScriptDir for the file directory the running script is located in

autohotkey.com/docs/Variables…
14. My favorite hotstring sigil is `;`, because there's basically never a situation where an alphanumeric character follows a ; in English or software.

15. Gleefully abuse the "hotstring helper" at the bottom of this link, it's great

autohotkey.com/docs/Hotstring…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Hillel

Hillel Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @hillelogram

May 13
What would a language designed entirely around teaching beginner programmers look like? Here are four examples:

1. Scratch: designed for teaching children. Instead of coding in text, people snap together "blocks" of code like jigsaw puzzles.

scratch.mit.edu/about https://scratch.mit.edu/projects/3296047/editor/
While you could teach adults with Scratch, they'll probably feel patronized. Scratch's tutorials are all aimed at kids, and the language primitives are for art and games, not business or automation.
2. Quorum: an "evidence-oriented programming language". Fairly typical OOP lang, but with design decisions based on empirical studies of what's easiest to learn to and use. For example, STM over locks, static typing, better keywords and compiler errors

quorumlanguage.com
Read 16 tweets
May 9
Hot take: Python is fundamentally the wrong tool for layfolk programming.

All existing programming languages are the wrong tool.

They're all designed for *software developers*, who are specialists.
Aella expected Python to be like other "computer skills", where you can poke at it until it does what you want. And you can do this IF YOU ALREADY KNOW HOW TO PROGRAM. But it's not clear to layfolk that programming is so different from reg computers

When we say Python is a good "first language", we mean it's good a place to start building the *fundamental knowledge* of software development. If you don't build that knowledge, programming is nearly impossible. Again, that's not clear to Aella going in

Read 13 tweets
May 6
One of my favorite things with learning about new programming languages is seeing all the "small ideas" that could easily be picked up by other languages. Here are some examples:
D has a special "unittest" block as part of the language syntax, instead of relegating it to a framework. You can have the unittests checked on every program run if you want

dlang.org/spec/unittest.…
In Eiffel you can mark any method as "obsolete". JVM and .NET do something similar as an attribute, I think it's neat how in Eiffel it's a part of the language semantics

eiffel.org/doc/eiffel/ET-…
Read 11 tweets
May 6
Here is the difference I think *they* are trying to make:

* "Coding" is a general term for developing any kind of software
* "Scripting" is a subset of coding, for making bounded linear "uncomplicated" batch jobs that assist people.
Scripting has a lower entry barrier than general-purpose coding. It's also a lot "easier": a beginner scripter can do a lot more with scripting than a coder can do with coding. For these reasons, general-purpose coding is considered more prestigious than scripting.
In my opinion, this is a very good thing. Scripting SHOULD be easier than coding, because then it's accessible to more people. You shouldn't have to know about testing, version control, packaging, modularization, and API design if you just need to scrape a few websites
Read 7 tweets
May 6
Nuclear take: XML is actually a great format for adding metadata to unstructured text. It just sucks for representing structured data, which is, uh, what all the tooling and tutorials assume you're using it for
Why would you want to add metadata to unstructured text? To get metafiles, of course! I'm using it to store a series of iterations to a piece of code in one file, which I then use for making tutorials <spec name="threads_liveness" num="4"> -
You can tell this is Not Intended Use Case because all the tools are super weird about text following tags that aren't in other tags, even though that's the whole benefit of XML over JSON and YAML— inline markup
Read 5 tweets
Jan 23
This is seriously messing with my head: the Dunning-Kruger effect might not be real! I read all of the linked papers, and they make a convincing argument that it's more likely to be a statistical artifact than a psychological effect: mcgill.ca/oss/article/cr…
The DK paper grouped test scores by quartile and plotted scores and self-perception, giving the famous X-shape. Turns out, you get the same shape if you do the same with completely random data! What you need to do is compare each *individual's* test score and self-assessment. One of the famous graphs fr...A simulation where each &qu...
The critics studied a lot more people: 1100 vs DK's 60-80 undergrads (all from one classroom). Most individuals were pretty accurate with self-assessment. But when they did the same "quartile" aggregation, they got the famous DK x-shape! Good evidence it's a statistical artifact. A thousand individuals, tes...The same data, aggregated b...
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(