News for hackers. Stuff that matters.
Re:Learning to code vs. learning to automate by nickjj on Sunday December 08, 2019 @04:48PM (#21738607)
> Theoretically you can do the same thing that AHK does in a .net language or even Powershell but AHK is just easier to whip up something very quickly.

This is exactly how I see it too. 10+ years ago I would have written a C# app to do something that I can now do in AHK.

Of course there's limitations (I wouldn't write a super intensive native app in AHK) but for little workflow optimizations it's so good.

For example, I wanted a quick and dirty way to grab the hex color under my mouse cursor and copy it to my clipboard. With AHK it was:

    #h::
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%, %MouseY%
    StringLower, color, color
    clipboard := SubStr(color, 3)
And now when I press Windows + h as a global hotkey it does what I want. I set it up to start when Windows starts and it uses 1.5MB of memory. Can't really beat that for overall efficiency (few minutes of coding, doesn't take up much resources, etc.).

A while back I wrote a blog post on using AHK for defining global hotkeys. I still use that method today. If anyone cares, that's at: https://nickjanetakis.com/blog/remap-and-set-global-hotkeys-...

Re:Learning to code vs. learning to automate by kiddico on Monday December 09, 2019 @11:13AM (#21743790)
Your hex snippet produced my usual outcry when I read other's AHK scripts: "Wait, you can do THAT?!"

It's been added to my growing toolbox(which I lovingly call i3_emulator.exe), thanks!

Re:Learning to code vs. learning to automate by nickjj on Monday December 09, 2019 @12:05PM (#21744235)
The fun thing about it is I wouldn't classify myself as an AHK developer. I just picked apart a couple of scripts that I found on Google.

You can kind of understand what's going on with general programming experience and double checking their documentation.

In the hex code example it almost reads like pseudo code. Get the mouse position and store it into X / Y variables, grab the color under the mouse position, make it all lower case, copy it to the clipboard but trim out a few extra characters that was returned by a previous step.

How is your i3 emulator going? I tried that one tiling window manager AHK script (bug.n) but found it to be a little too buggy to use.