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: 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”