AHK: How BGR Color Works

Sadly, in AutoHotkey scripts  you can’t just demand “LIME” or “GENTLY BURNT ORANGE”. The computer will spit out an error message if you try. It requires a color ID in hexadecimal BGR (Blue, Green, Red) format.

If you’re wondering what the hell that is, you’re not alone.

The simple answer? It’s an 8 digit code assigned to each color. Look them up on Google if you want to preserve your mental health.

Keep reading if you’re less partial to your sanity.

The Complicated Answer

I just relearned how to count, damn it. That’s how complicated this is.

Hex Explained

You see, Color ID’s are made up of a fixed prefix and numbers that represent a combination of blue, green and red.

The amount of those colors can be anywhere between 0 and 255. Here starts the problem of counting. How do you tell the computer to use the max green value (255) if you can only use a 2 digit number?

You use a different counting system by adding letters A-F. That’s how.

BASE10LOWRES

It’s Base-16 because you’re counting by combining 16 characters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f.

If you’re only manipulating one color while the others are at 0, all you really need to know is that lower values are darker than higher ones.

16-BASE EXPLAINED

When you start combining colors, the same normal color rules apply. To make yellow, you jack up the red and green values, so the BGR will read 0x00ffff. Blue and red makes purple, so 0xff00ff.

The oddest thing to get used to is white being the max value of blue, green and red combined, 0xffffff. Just remember that the higher the value, the more they cancel each other out until they reach nothing. White.

AHK: How to Automate Mouse Movements

Automating mouse drags is… Not as useful as I expected. But wildly helpful if you need to draw the same thing on a computer repeatedly. Keep in mind, it only works with straight lines. Quite wonderfully, you can control that line entirely down to the pixel.

Hello

Continue reading “AHK: How to Automate Mouse Movements”

AHK: How to Lose Friends & Alienate People with Code

Automating keystrokes is a fun way to spend an afternoon. It’s also an entertaining to wrap your head around the idea of loops and variables. If you’re wanting extra practice, give these a try.

Note: You’ll need AutoHotkey installed for this. If you don’t know what that is, click here.

Important Commands to Note:

run, Name of Program.exe
SendInput Keystrokes to Send
Sleep, Delay in Milliseconds

Loop, # of times to run loop
{
Commands to run
}

All Work and No Play

Take a look at this code.

run, notepad.exe
Loop, 100
{
SendInput All Work And No Play Makes Jack A Dull Boy.
}
return

Keep in mind that everything inside the loop will happen 100 times, so with just 6 lines of code, you can make the computer type this sentence over and over again. In action, it kind of makes your computer seem possessed.

Dull Boy

Continue reading “AHK: How to Lose Friends & Alienate People with Code”

AHK Update: Targeted File Deleter Program

Welcome to the combo post of How to Delete Every Other File in a Folder and How to Make a GUI. For lack of a better name, I’m calling it a targeted file deleter program. It can automate the process of deleting every other file if the file name ends in sequential numbers.

For those who couldn’t care less about how it functions, just follow these two steps.

STEP 1: Fire up a new AutoHotkey* file.
*Download it here if you haven’t already.

STEP 2: Paste this text inside. And run the file.

Gui, -Caption
Gui, Color, Black
Gui, Font, cWhite s12
Gui, Add, Text, , The Targeted File Deleter
Gui, Add, Text, , Note: File names must be sequential (for ex. IMG_1.jpg) and cannot have leading zeros (IMG_001.jpg).
Gui, Add, Text, , What is the folder you want to delete files from? (Ex. C:\Users\Desktop\)
Gui, Add, Edit, vFilePath w500 cblack
Gui, Add, Text, , How does the file name start? (Do not include numbers)
Gui, Add, Edit, vFileNameStart w500 cblack
Gui, Add, Text, , What number does the file name start at?
Gui, Add, Edit, vFileNumberStart w500 cblack
Gui, Add, Text, , By what increment do you want to delete files?
Gui, Add, Edit, vIncrement w500 cblack
Gui, Add, Text, , What is the file extension? (Ex. .jpg, .pdf, .doc)
Gui, Add, Edit, vExtension w500 cblack
Gui, Add, Text, , How many files have you got total?
Gui, Add, Edit, vLoopCount w500 cblack
Gui, Add, Button, x570 y370, OK
Gui, Add, Button, x570 y410, Cancel
Gui, Show, , The Mass File Deleter
return

ButtonOK:
Gui, Submit
Loop
{
if A_Index < %LoopCount%
FileDelete, %FilePath%%FileNameStart%%FileNumberStart%%Extension%
FileNumberStart+=%Increment%
}
return

ButtonCancel:
ExitApp

Continue reading “AHK Update: Targeted File Deleter Program”

AHK: How to Make a User Interface

I loathe ComputerSpeak.

Missed commas. Misspelled commands. A { instead of a ( because those bastards look exactly alike. Opening the script guarantees that I will make at least one of these errors while updating the code to do something slightly different.

So in order to combat this, I’m making my script a muzzle.

Call it a GUI (Graphical User Interface), call it a window, call it a box-it’s all the same to me. Essentially I’m turning this jumble of script on the right to this nice, soothing thing on the left.

GUI5

In the interest of keeping it simple, let’s make the simplest GUI possible and build up from there.

Continue reading “AHK: How to Make a User Interface”

AHK: How To Delete Every Other File in a Folder

STEP 1: Make a new AutoHotkey file. Not sure how to do that? Click here.

STEP 2: Right click your new AutoHotKey Script → Edit Script.

STEP 3: Copy and paste this text into the body.

Var = 8071
Loop, 100
{
FileDelete, C:\Users\Desktop\Sentient Webcam\IMG_%Var%.jpg
       Var+=2
}
return

STEP 4: Go to the folder with all the files in it, and copy the file path so the computer knows where to look. Paste that in place of the red text in the script.

FilePath

Continue reading “AHK: How To Delete Every Other File in a Folder”