A 7-post collection, I love you, and I'm blocking your ads

An advertisement has never persuaded me in my life. Okay, I'm lying. When I was a wee little boy I distinctly remember seeing Batman and TMNT toys, and LEGO bricks, and other fantastic things on television and begging my mom to buy them for me, and she did. Even then they were never as fun I was manipulated into believing. So, they got me there, and then I grew up.

Beyond that, I'm being honest and forthright. I have never bought something from a commercial, and I wouldn't even say I've been persuaded by a commercial. Influenced? Yes. I've been pissed off (no not at something they intended), and I've had my train of thought and viewing experience interrupted.

Climbing onto my soapbox, let me espouse how much I love to see televised material that is strictly relevant to my interests.

Everything I watch on my television is through my DVR system. Everything. If I bump into a show airing I enjoy, I schedule it to record and I watch it an hour later, where I can hit that wondrous fast-forward button. If it's a live show? Same thing. Important news relevant to me? Same.

Now Hulu, I love your service, and I understand the advertisement based model. I'm glad there's such a model (though I contest most is utterly broken in their interest-based irrelevance) and that it can support you (I hope it's enough for you, perhaps not!). Additionally many of the things I love rely on advertising. Favorite websites, and consumer goods too.

That said, I have never clicked an ad seriously. Never. We are becoming a pull society, not a push one. I don't watch the news. I don't read the newspaper. When I wish to know something, or what's happening in a particular field, I perform a search, just when I want to. I use Google Voice for my cell phone. I sign things with disposable email addresses, I don't get coupons in the mail. I even apply it to cleaning. Why would I want all of this garbage when I can seek it out precisely when I need it?

So I use Adblock software. So I screen my calls. So I only fake sign-up for subscriptions. Advertisers, I don't mean to be rude by blocking your ads; I'm saving you bandwidth! I'm not ever going to click one. I'm never going to watch one of your commercials. I don't even second-hand listen or watch your commercials when someone else is.

In fact I'm passionate about it, passionate enough to spend hours, even weeks if necessary programming around these sort of annoyances. The payoff is worthwhile to me when I can watch entertainment without my mood ruined with advertising drivel, and I consider my mood to be highly important!

So, Hulu, I blocked your ads. I blocked them in the most reliable "there's nothing that can be done about it" sort of way. I screen scraped your advertisement notice which of course you'd do far more inconvenience to your users by discarding. That simple fact means I will always be able to detect ads. If the user is informed an advertisement is playing, then I'm informed.

I don't think you'll mind though, that I'm opting out. Am I even the issue? Perhaps someone may package my code in a tidy little consumable disappearing your ads with nary a consideration, and the occasional or rare advertisement sucker may cease being suckered altogether, or miss something they'd enjoy. Are there really enough of these characters to make a difference, maybe even ones that knowingly use an Adblocker? I can safely say I'm not one, no not even the rarest of clicks or purchases would ever register from me. Zero.

Blanked out advertisement.

If you're not like me, if you'd rather watch an ad than black nothingness (later I'll add fun substitutions), or if you occasionally are persuaded by an advertisement, or they simply get into your awareness and on your tongue and you do not mind, then enjoy your advertisements and support Hulu, because they deserve such support after all.

Download the AutoHotkey script to block Hulu advertisements.


Coders: better gamers than you? Take FreeSpace 2

(Because we cheat!) Well that's the theory anyway. Except then we stop gaming because we're bored and we go back to coding our cheats.

So I recently dusted off the game FreeSpace 2. Still fantastic, and thanks to the FreeSpace 2 Source Code Project it has new and pretty graphics and mods. Metacritic thinks it's awesome too, scoring a 91… if that means anything.

MediaVP updated graphics screenshot, enemy ship targeted at 367 meters.

In a space combat sim, deftness and accuracy are your best friends. Unfortunately in FreeSpace it didn't seem that you could have both. With the sensitivity maxed you could pivot, bank, and pitch with maximum speed, but your target would bounce around your reticle, and you'd miss most of your shots.

Perhaps a very nice gamepad joystick would register a wider range of the slower, gentler movements. Mine certainly didn't, and that might be the most common experience. A standard computer mouse absolutely doesn't work, because there's no "center" to return to: you're constantly turning.

I of course thought, "Ha ha! I can fix this" and turned toward AutoHotkey. I was going to code an ugly hack, and have a button or joystick open the key configuration and adjust the sensitivity in a lightning quick second, preserving the state of my other buttons and ship movement.

That is until I spotted an example script in the very awesome AutoHotkey documentation for using a joystick as a mouse. Programmatically controlled sensitivity, some significant rewriting, and yeah: dominating.

I have one joystick for movement, the other to adjust the sensitivity/speed of that movement for excellent ship tracking, and a button which brings it to the absolute maximum for rapid orientation changes. Also many other intuitive combinations for interacting with enemy/friendly/escort ships such as targeting, targeting attacker, and so forth.

Here's the codez.


User interfaces... it's all about minimal user interaction

Designing user interfaces. It's not that hard.
Okay, it's really hard, but two central ideas strike me:

  1. Users like to do things quickly, and if you're quick you can be efficient.
  2. The more clicks or button presses it takes to accomplish what you want, the slower it goes!

Now complexity is its own bane—and it can be a worse one, but it's all about balance.

Ideally your most used functions should be within one key press / mouse click, lesser ones two, three, and so on, adding organization as you go.

I don't think this is very difficult to understand, which is why cell phone interfaces can be particularly frustrating.

What phone applications are the most time sensitive? Phone, Camera, MusicID, flashlight. Put them on hard buttons! At least a hard button that launches a wide menu which makes these options immediately selectable, but remember that when you go from one to two buttons you're doubling the amount of actions required, the most significant a one value increment can be.

Just keeping these points in mind is enough for much lauded user interface innovations to be obvious. Just take a look at new features of Windows 7 and you'll see what I mean. It doesn't take a company like Microsoft to come up with these things.

A while back I made an effort to emphasis the importance of minimal user intervention in relation to Vista and XP's taskbar, and it's interesting to compare and contrast those supplemental 3rd party tools with the Windows 7 taskbar.

Though I didn't mention it in that post, I had also written an AutoHotkey script to accomplish the Apple-esque (and now Windows 7) task of focusing an application's window if one existed, and otherwise launching a new instance of the program.


programPath = %1%
launchState = %2%
winTitle = %3%
excludeText = %4%

if 0 = 1    ; left side is always variable
    Loop %programPath%
    fileName := A_LoopFileName
    Process Exist, %fileName%
    processId := ErrorLevel
    if (processId)
        winTitle = ahk_pid %processId%

SetTitleMatchMode RegEx
WinGet windowUID, ID, %winTitle%,, %excludeText%
if %windowUID%
    WinActivate ahk_id %windowUID%
    ; replace commas with escaped commas
    StringReplace programPath, programPath, `,, ```,, All
    Run %programPath%,, %launchState%

Compiled as launchOneInstance.exe you would assign your launch/focus shortcut as follows:
"C:\path\to\launchOneInstance.exe" "C:\path\to\program.exe" Max "Program Window Title"

Max/Min/Hide or simply "" are fine for the launch state parameter.

Windows 7 is a wonderful experience when it comes to application launching, but cellular phones remain horrible, including Windows Mobile devices. Manufactures and carriers have their own influence, but even Pocket PC user customizations seem to miss the mark again and again.

Minimal interaction, guys! Minimal interaction! Why pull up the task manager to check for an app when you can launch/focus it from the start menu in equal or less clicks? Why not launch the start menu from a hard button for easy access even within full screen applications? Add an extra column to that programs list if it fits easily, we don't want no damn scrollbars!


Curse you focus stealing! What did I just authorize?

Window focus stealing has been around for a long time, there's a Wikipedia article on it, it's been asked a few times on SuperUser and there's apparently a ForegroundLockTimeout registry value that may assist. But it probably doesn't.

The fact is that some applications don't respect system settings, and steal focus anyway.

You can probably write code to take your focus back, possibly even fast enough to avoid the thieving app from receiving dangerous input.

AutoHotkey, is, once again, ideally suited, and this problem is certainly under discussion on their forum.

So I stole some last active window code and a bit of UAC elevation code, and we've a means not to stop focus stealing (sorry, haven't given that a go yet) but at least to record a history of focused windows so we can see exactly what process / window it was that stole focus and intercepted our keystroke. What the hell did we just authorize? Well, we can know.

Install AutoHotkey, then download the script. Execute it and you've now a history of windows that have come into focus.

Drop a shortcut to "C:\path\to\AutoHotkey.exe" "C:\path\to\windowHistory.ahk" into your start menu startup folder to always have it running. Now find and double click the new AHK icon in the notification area to open the script window, from the View menu select Variables and their contents. At the bottom you will see the variable winNum, which is the most recent recorded window index.

window history

The last 30 windows and their processes are listed here, saved to these variables in a loop. Go to the one matching the winNum value for the latest and count backward to see the windows in focus prior (after zero you jump back to twenty-nine). The number after process names is the PID or process identifier, you can match this to an exact process in task manager.

This is crude and not much more than a copy paste job, but it demonstrates that we don't have to live with these frustrations, we can take action.


Gaming the game: Cheat Engine, AutoHotkey, and Jedi Academy

Pretending to be a Jedi can be a lot of fun; it makes you feel awesome. But what's even more fun is writing code to actually be more awesome. And that, my friend, is the most awesome thing of all.

Which brings us to Jedi Academy. If you fall, you need to get up. If you're force choked, you must retaliate or be strangled to death. It's predictable, it's repetitious, and you could be a whole lot more awesome at it. Why press a combination of buttons to execute a special move when you could use only one, with complete reliability? It's like what a programmable controller did for my Mortal Kombat prowess, with an even faster reaction time.

programmable controller

This type of botting (gamer augmentation?) is a bit more like WoWGlider than an aimbot or trainer, but they're all fairly similar. It's essentially interaction with the game's memory that makes this type of coding difficult, but with the right tools and some good examples you can be on your way.

Cheat Engine

The most important tool in your arsenal is the memory scanner (and more), Cheat Engine. Knowing the circumstances of your character, opponents, and environment means reading the game's memory, and with CE you can find the appropriate memory addresses for things such as health, position, and action/animation.

I tested a lot of memory scanners, and CE was easily the most powerful and useful, capable of many advanced features. To get your foot in the door using CE try the built-in tutorial, which is also explained on the forum. Becoming truly proficient with CE is hard work, you'll need to reason about data types and arrays of structures representing characters and items, learn to master pointer scanning and pointer integrity testing, and certainly remember to save your work. You might need to break out Hex Workshop to compare memory dumps: "Ah, this value is the same for each tauntaun, and a different value is the same for each health pack. Must be entity type!"


Of course you'll need a language/program to code in. I chose AutoHotkey because it's designed for sending mouse and keyboard commands (as well as manipulating windows, controls, and plenty of other things) and I'm familiar with it. Some further information:

  • it's very lightweight (<2mB)
  • it's phenomenally well documented (in fact, the best I've seen!)
  • scripts aren't natively compiled, but should be as fast as you'll need
  • scripts can be bundled with AutoHotkey to make stand-alone executables (.exe)
  • Dll support, such as the standard Windows API, via DllCall
  • Graphical user interface (GUI) support
  • Large community

Now AutoHotkey doesn't have built-in memory management functions, but that's why I wrote my own.

Jedi Academy

Jedi kickin' ass

Current features

  • Allow you to execute a special move (lunge attack, flip attack, and cartwheel) with one keypress, while retaining your character's movement. (This was trickier than you'd think, and it's really cool.)
  • Allow you to hold down a button for mindtrick, and have your Jedi confuse whomever you look at, without wasting force if they're already tricked. (This is really fun and makes specifically mind trick level 1 quite powerful.) The already-tricked routine needs some work though, see code.
  • Automatically kill whomever you look at if you so desire.
  • Automatically retaliate with force pull if choked.
  • Automatically jump up if knocked down.

Partially implemented

  • Instantly kill an enemy with a force choke smash into the ground.
  • Perform a sideways cartwheel attack but actually fly forward, not left or right.

Easily added

  • Make dynamic doors disappear by changing their item type and walking on through!
  • Change item types so health packs give you grenades, etc.
  • Move certain level elements by changing their coordinates. (Unfortunately only works on already animating things, like the rather wickedly deadly vent fan at the intro of the prisoner rescue mission. I'm sure it's possible to make it work on any entity somehow.)

Crazy ideas

  • Perform a flip attack but spin around to actually continue facing forward.
  • Determine the most deadly attacks in the Jedi's arsenal by recording average duration of animation sequences vs. damage inflicted.
  • Automatically scan for certain nearby items, turn to face, perform an action. For example, automatically force pulling nearby health packs and grenades, without interrupting the player.
  • Automatically saber throw accurately into groups of enemies (okay, this one is another level up in complexity).

Let's have it!

Download the code files and install AutoHotkey. Then edit some configuration values at the top of the main script, and run it. After that your Jedi Academy game should be "enhanced".

If you have trouble or do anything really cool with it let me know in the comments.