AHK: How to Write a Web Scraper
I love AirBnB. But every now and then, I don’t want to scroll through multiple pages of listings to find a place to stay. I just want to be able to see a simple spreadsheet. That’s exactly what a web scraper is meant to do.
AHK: Making a User Interface with Graphics
So you wanna prettify your user interface? Maybe make some custom buttons and use your own image instead of the default grey box on the left?
It’s actually not as difficult as I was expecting. All you need is a program like Photoshop or Gimp to make the .png, .jpg or .tif for your background and any buttons.
Continue reading “AHK: Making a User Interface with Graphics”
AHK: Visualizing ELSE/IF with Arrays
So Hopper’s Amazing Decipherer Script 1.0 was about 472 lines because it included ELSE IF clauses for every letter in the alphabet.
HADS 2.0 cuts it down to 77 lines because arrays, as it turns out, are incredibly useful when paired with loops.
Making a Rotated Alphabet
Deciphering a Caesar cipher requires that the alphabet be moved up by a certain number. Like so.
Notice that this is basically a 2-step process. Turn the letters of the alphabet into numbers 1-26. Then add the rotational value to each of them to find their new positions, in the code below that’s assigned to a variable called indexVar. In ROT1, A =1 and the rotational value is 1, so A = 1+1 = 2.
But what happens when you hit Z? Z=26 and the rotation is 1, so Z = 26+1 = 27.
So, you want to tell the computer IF the number goes above 27, then you want to reset it to 1 and continue.
A Slow Motion Loop
AHK: What is an Array?
Arrays are a damn godsend. More specifically, they’re an easy way to deal with large lists. Why is this useful you ask? Imagine you want to run the same code on multiple items. The items could be numbers, letters, words, full sentences—anything. By putting those things in a list, or an array, you can loop through hundreds, even thousands, of items with just a few lines of code.
AHK: How to Decipher the Caesar Shift with Code
VG JNF N OEVTUG PBYQ QNL VA NCEVY NAQ GUR PYBPXF JRER FGEVXVAT GUVEGRRA JVAFGBA FZVGU UVF PUVA AHMMYRQ VAGB UVF OERNFG VA NA RSSBEG GB RFPNCR GUR IVYR JVAQ FYVCCRQ DHVPXYL GUEBHTU GUR TYNFF QBBEF BS IVPGBEL ZNAFVBAF GUBHTU ABG DHVPXYL RABHTU GB CERIRAG N FJVEY BS TEVGGL QHFG SEBZ RAGREVAT NYBAT JVGU UVZ
-No idea what this says. Damn you, Caesar.
The Caesar Shift is supposed to be ridiculously easy to decipher. I say supposed to be because while it might be easy to crack, translating the bastard is mind-numbingly painful if you have a substantial block of text.
There are quite a few resources online that’ll do it for you, but for kicks, I wrote an AHK that automates it—if you know how many positions you want to shift.
So How Does the Shift Work?
Continue reading “AHK: How to Decipher the Caesar Shift with Code”
AHK: How to Extract Every Hex Code from an Image
Say for some reason, you really wanted to know the hex code for every color in an image. And you really wanted to use AutoHotkey. This is the program for you.
Continue reading “AHK: How to Extract Every Hex Code from an Image”
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.
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.
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
returnButtonOK:
Gui, Submit
Loop
{
if A_Index < %LoopCount%
FileDelete, %FilePath%%FileNameStart%%FileNumberStart%%Extension%
FileNumberStart+=%Increment%
}
returnButtonCancel:
ExitApp
Continue reading “AHK Update: Targeted File Deleter Program”