Hacker News new | past | comments | ask | show | jobs | submit login

I learned programming with AutoHotkey when I was 15.

I first used it to automate grinding gold and items in a simple flash-based RPG for me and my younger siblings around ~2005. At first it just clicked certain locations that buttons would be on a fixed schedule to advance a quest to the end and repeat. But then, being a flash game after all, sometimes it would take a second to load the next screen which throws off the timings and breaks the sequence. So I changed it to wait for pixels to change color as an indication that something finished loading and to start the next sequence of clicks. But that didn't end up being very reliable because the colors & locations weren't always exactly the same, so I updated it to take a screenshot and use it to find the average color of an area of the game where a button would be which ended up being a much more reliable timing indicator. But then it was very slow/used a lot of CPU (and I needed all that CPU to go to running the flash game in a 2005 browser on a 2002 dell), and using a scripting language to sum up 100k pixels every frame just wasn't fast enough. So I wrote a single C function to do the color averaging on a byte buffer, copied the raw compiled machine code (as hex) into AutoHotkey and directly called it with DllCall to get the summed result: ah, much faster. But there was still an unreliable aspect where the position of the game in the browser window and the location of the browser window was fiddly to configure, and my siblings had a hard time getting it set up. It turns out IE used standard windows controls in the browser which (if you look in the right place) exposed the location of the flash bounding box, and with some calculations relative to the browser window I made all the click locations relative to the flash window, which solved that problem. It think it also supported browser scaling because we liked to play it at higher than 100% zoom.

I ended up being more interested in the programming than the game, and my first published project was an array library to make working with associative arrays (where each element is a separate variable myarray1, myarray2, myarray3 etc) easier with insert/delete/append etc operations, before AutoHotkey added true arrays and objects.

Then I went to university for chemistry for 2 years before getting my wits about me and realizing that I would probably be more interested in CS.




> copied the raw compiled machine code (as hex) into AutoHotkey and directly called it with DllCall

Holy potatoes, you can do that?! Or, I suppose, you could do that, because I half-expect you can't anymore with all the various security features that were added to Windows over the last two decades. But cool stuff nonetheless.

It reminds me of my own foray into the space of running assembly output; back in my teenage years, I compiled a small bit of assembly into an object file, read it into a C++ program, casted the string into a function pointer and executed. Surprisingly, it worked. I got the idea from StarCraft modding scene; in those days, if you wanted to add a new button for your unit that did something, you had to write the action in assembly, compile it with MASM, and then let StarGraft tool patch the game executable with it (I don't remember if it did it at runtime or modified the actual executable).


Yep! Actually I'd bet it still works today. I was able to find it in my Dropbox (2005 me's solution to version control). This is the function that does the dirty work [1]. That gist also has the C source as well. Date modified on these files are ~2008-9.

[1]: https://gist.github.com/infogulch/d88b956ddd86bd00b351649511...


> I ended up being more interested in the programming than the game

I’ve been a swe for years, but this is how I felt about Pokémon go before they started blocking the apis people had developed. My only goal was to catch all 151 Pokémon. Because of where I live, I had a very hard time finding pokestops so I looked into and found the apis.

I was able to grind out lvls and catch Pokémon, spin stops, etc. I won’t go into all the things I did, but it sure was fun. I suppose I was harming the game because I wasn’t spending real money on in-game items, but besides that I don’t think I was harming any of the other players.

APIs got shut down, haven’t touched it since.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: