My first attempt at writing scripts in Autohotkeys

You know, I quite enjoy builds with a lot of buttons to press, but when it comes to melee abilities it pisses me off a lot. The examples are numerous – beronath spellbreakers that use LA as a buff, literally any melee build with Oleron’s Blood. Today I started a shield soldier and having to use Slam and Shield Slam from components I finally snapped and decided to make them automatic, and downloaded autohotkeys.

The idea was simple, really. When LMB is held buttons “Q” and “W” should also be held.

After going through a few basic examples I wrote a simple script to do this, and it worked, but less then perfectly.

First of all, turns out you can’t really hold more than 1 button in GD, so I had to rewrite it into loop that presses “Q” and “W” once in 50ms.

Then I faced a spam of “skill not ready” so I had to increase delay to 3.8 seconds (up to biggest cooldown of Slam, which was 3.5 seconds, plus some margin).

The result was working somewhat satisfying, but there was one more glitch I wanted to fix. At times a character would just swing a weapon into the air. It’s quite easy to immitate – get a Slam, target a ground close to your character and hold a button – you would constantly swing into the air as if pressing shift. It also happens if you say stumble on something while walking and get stuck for a moment due to imperfect pathfinding.

At first I didn’t knew how to fix it, but then I found that there’s a feature of searching image on screen, and surprise – when you target an enemy the cursor changes. So the idea was just to turn off the script if image not found to prevent accidental swings when travelling.

Next thing I found out that a cursor just doesn’t show on screenshots, so I recorded it on the video, and then did a screenshot of a video. This was a quite stupid thing to do.

First set of tries – the image is found when it’s open but isn’t found on neither video nor the game. The reason was I converted image to .gif for some reason and gif really distorted colors. So I switched to using .tiff instead.

Second set of tries - .tiff is found on the video but not in the game, and nothing helped. Decided to switch an object for test (which was a random yellow Gazer Eye) and same thing – it’s found on random screenshots and the paused video but not in the game. But then before giving up for good I downloaded a Gazer Eye image from gracefuldusk aaaand…it worked! Turns out that both screenshots and video already distort the image a big deal.

Final set of tries – inspired with success, I used modding tools to extract the game resources and then tex viewer to save the original attack cursor in bmp. Failed, but found out that I mirrored the file the wrong way (yup, tex viewer saves in bmp but somehow rotates and mirrors the file). Now everything was perfect aaaand…no, it didn’t worked. No idea why. Perhaps the fact that cursor doesn’t shows on screenshots is because it’s not actually rendered on screen and is kind of an overlay.

Kinda frustrating and disappointing. But not bad for a first try I guess.

Nice to see others work on this as well. I found SetTimer to be pretty useful when skills have different cooldowns and then I made a Reload hotkey to stop all timers.

For ImageSearch I tried getting it to work but failed as well. I read somewhere screenshots somehow change the image so ImageSearch will not find it ingame, they recommended a professional screenshot tool and that is where I stopped. Another hint was to use windowed mode but I had no success with that either.

I did manage to have successful ImageSearch when using only a single pixel as search image but didn’t have the energy to invest more time into it.

What worked nicely is keeping up different buffs like PB and BoD simultaneously and doing some weapon swap magic so I could use devastation or other skills, but not having the component buffs is annyoing.

The experiment where I searched for a central part of a Gazer Eye worked successfully in fullscreen, but when I returned to toying with cursor it didn’t worked in neither fullscreen nor borderless window. Didn’t bothered to try normal window mode.

A single pixel will end up triggering a lot of false positives, I think.