The Autohotkey Thread

Finally, we can concentrate on strategy instead of drudgery!

First off, thanks to Robert Hentschke for mentioning this gem:

http://www.autohotkey.com/

My biggest beef with this entire series of GC2 games is the drudgery that is involved. As far as I am concerned, the Fun Factor is severly diminished by the endless repitition involved in populating planets and manually buying ships. Even Stardock personnel have gone on record with a similar statement when they announced the Planetary Governor for ToA. The problem gets much worse when you use a large monitor with 1680x1050 resolution. Especially if you have bifocals.

This hotkey program allows the user to create simple macros that instruct the mouse to click on certain coordinates, and also automates keystrokes. The combination is a godsend for people like me who have wrist problems and don't like to have to squint at the screen. My favorite macro enables me to assign a Planetary Governor in ToA, then jumps to the next planet. That saves me 1,200 Clicks and considerable discomfort if I assign a PG to 300 planets!

+1::
click 1456, 827
click 955, 432
click 842, 460
click 837, 564
Send x

+1= the Shift Key and the number 1

The coordinates are based on my screen resoloution, and represent the sequence of action initiated in the Planet Detains screen. One of the AH utilities will let you see the mouse coordinates on your screen. Since they will likely be different from mine, you will have to alter the code for your computer.

Send x jumps to the next planet. Send z would jump to the previous planet.

This simple utility makes the game FUN again! I can now concentrate on the finer points of strategy instead of the drudgery. Make no mistake, this utility alone will not improve your score. You still need practice and experience.

28,831 views 21 replies
Reply #2 Top

I was starting to wonder when a moderator would start slapping wrists and splitting the Kzinti thread. =P

Use this to "encase" several macros so they are only played back when actually in the GalCiv window.

SetTitleMatchMode, 2 ; tells AHK to search anywhere in the window title for some text
#IfWinActive GalCiv2 ; playback if the active window title contains GalCiv2

^k::
Send ^d  ; remap CTRL-k to CTRL-d
return

^h::
Send ^i  ; remap CTRL-h to CTRL-i
return

#IfWinActive ; end of directive

PS: Is there a logical reason for why CODE tags don't work at all round here?

 

 An endless loop (note the cleverly hidden pun!) that plays back the code for as long as you hold down the End key. Or rather - weigh it down with your old metal d20 :

End::

Loop
{
Sleep 10
GetKeyState, EndButtonState, End, P

if EndButtonState = U
break

Send, x
MouseClick, left,  690,  612
Sleep, 50
MouseClick, left,  465,  680
Sleep, 50
MouseClick, left,  620,  599
Sleep, 50
}  

Since the actual mouse click position depend on your resolution - no big deal. The auto recorder catches all and you merely cut/copy the parts you want. Add waits until it runs smoothly.

+1 Loading…
Reply #3 Top

Make no mistake, this utility alone will not improve your score. You still need practice and experience.
"Intelligent" macros are a massive undertaking and a ridiculous idea for a strategy game. For twitch games they can be a huge benefit, taking some idiotically complicated mouse maneuvers outta yer hair.

The full scope of Autohotkey is far beyond what a few posts here can show. This thing is... huge.

You could pop up input boxes, using keys to select which financial plan to use for a certain rushbuy. Could use macros to record/restore certain positions on the mini map like in a typical RTS to snap to a predetermined map area. The true limit is your imagination. Train that muscle. =P

It can react to the "environment" in some ways, like reading the colour of the pixel at a certain screen positions. Still, an "intelligent" use of bonus tiles is hardly possible. The length of the available projects list constantly changes during gameplay as well as the names of the projects and therefore their position in the list. A pretty hopeless case.

Besides, there are too many variables outside the direct bonus tile consideration, such as an Eco starbase array that would massively boost research on the planet or the complete irrelevance of factories on the planet because you plan to rushbuy everything on this colony #317.

 

Upgrading all ships in a certain square to a predetermined design is another possible use. Instead of upgrading all ships of that design in the universe, you could click through just the ones in this square.

As a preparation for this it might be useful to lead all your ship designs with a hull / number designation so that "C1 Constructor 7" would always be in slot 1 for cargo hulls on the upgrade select screen. So no matter what the current constructor design is, it's always C1.

It's a bit like organising the data in a database to be machine-readable. =)

Reply #4 Top

RH.............Don't think SD would object to something that makes their game better.  This definitely does.  Using a very simple macro coded with the AutoRecorder I saved an hour in one turn.

OK, whatever you say, you're not a scholar or a gentleman. }:)

 

Reply #5 Top

Quoting jacklv, reply 4
RH.............Don't think SD would object to something that makes their game better.  This definitely does.  Using a very simple macro coded with the AutoRecorder I saved an hour in one turn.

 

I am mildly surprised that SD did not develop something like this in their "windows-shiny-things" department that has GC2-ready macros. Now THAT's something I would have actually used Impulse to buy! It would also have saved them a boatload of grief from irritated customers.

I agree that this will both increase SD's GC2 sales and renew interest from existing customers. There are SO MANY things that I can play with now that I did not bother with in the past due to the drudgery-overload factor. Heck, I'll even play a game or two on Suicidal using the Arcean techs!

@RH: Nice macros! I'll put the endless loop to work! I may tie that one to one of my mouse buttons.

Reply #6 Top

Heh, Quite a few of us have/had been using AHK for a year or two. Indeed it is a great tool to get past some of the UI limitations.

Reply #7 Top

Yeah, you have and it is.  It is also something I have never read on the forums or thought to do so. My bad.  Neither does it explain why KP has the gold.  How many against one?  I personally have nothing to do with the standings nor does any other individual.  Scoreboard.

DA, you're a good Man and player.  Had to say what I said.

Reply #9 Top

It is also something I have never read on the forums or thought to do so.

IIRC the one to introduce it to me and the ToE was GalenEvil(Might remember him being in the MVL for a while). It was never outed much due to some people seeing it as cheating. I never denied using it myself cause it didn't really matter. Took me months to put in a big game either way :grin: .

Neither does it explain why KP has the gold. How many against one? I personally have nothing to do with the standings nor does any other individual. Scoreboard.

Not sure I get what your talking about or why your last line implies you think you stated something offensive. I have no vested interest in the meta much anymore, just play with my mod nowadays. Just though it amusing that AHK can now be talked about more openly as opposed to the past when there was still fear of reprisal.

DA, you're a good Man and player.

I always thought of myself as an average player that was just lucky enough to know great players and pick up a few things here and there, but I appreciate the sentiment. :)

 

 

Reply #10 Top

https://forums.galciv2.com/171278

Heh. Knew I was forgetting something. =P

 

Quoting Snarkotamus, reply 3678
I wonder if we could make a Planetary Buildout macro for DL and DA with this. It would be easy enough to populate tiles so long as the player starts with the same buildings in the same order of availibility every time. The trick is going to be getting the correct structures on the bonus tiles. This color-recognition could be the key.
There is also a chance that transparency and/or anti aliasing are going to mess with you there, not giving you fixed RGB values to work with. Some of that may even depend on the GFX board or drivers and then not work for "someone" even though you can't reproduce the inevitably reported "bug".

Been a long time since I played around with that feature but if you really want to create something usable, better pay attention to the detection routine. If there are unforseen problems then most likely with that. The actual code for what to build when - that's just math.

 

Someone would see AHK as cheating? How does that work?

I always thought the MV (which this is probably about) was a battle of wits, not about who has the sturdier wrists or a higher physical pain resistance.

Macros and/or bots in FPS/MMORPG are an entirely different matter. That does gain you more power, more frags, more whatever - especially in PvP environments. But in an offline strategy game? That's a bit... silly.

If your strategy doesn't work, the same strategy with an extra 2000 macroed clicks wouldn't work, either.

In X3 (my usual haunting grounds as "Gazz" =P) new players often equate mods/scripts with cheating... which is ridiculous. Most mods/scripts actually make gameplay more balanced (or harder) or fix bugs with the AI, interface, or gameplay. Still, many online players are conditioned to see all 3rd party "stuff" as hacks or cheats so they wouldn't even consider taking a look and forming an opinion for themselves.

Of course one can cheat with X3 scripts. It's pitifully easy. That's exactly why it's no challenge to all the scripters/modders there. A 5 line script may give you infinite riches and the best gear in the game but that doesn't get you any recognition or bragging rights. So why bother? =P AHK, however, cannot create any objects or credits. You can't use it to cheat, only to do the clicking you would do manually otherwise.

Reply #11 Top

Speaking of wrist-friendly macros:

MouseGetPos, xpos, ypos

*do stuff*

MouseMove, xpos, ypos

This returns the pointer to the position where you started the macro, avoiding unnecessary resetting of the mouse.

 

Going along the same line of thought, you wouldn't have to click the mouse if you want to do stuff with a particular tile on a planet.

MouseGetPos, xpos, ypos
MouseClick, left,  xpos, ypos

*do stuff*

MouseMove, xpos, ypos

Mouseover will do. Since you have to press some key to start the macro anyway, why would you want to press the mouse button yourself to select the tile?

Overkill? No. If you play GC for the score you have already accepted that there is no "good enough". No sane middle ground.

Reply #12 Top

I'll Definately use that first one!

*Note to Self: Turn off the macro that uses "!" before posting next time*

I'll look for some opportunities to incorporate the second one.

Reply #13 Top

Configuring freshly built stations for auto-build is another annoying item. You have to hit a very small check box and then click OK on the other end of the screen. Bleh.

That's not counting that you may wish to alter the default build order for this type of station at the same time.

Once built and quick-configured like that, I just reroute 8 constructors to this station and don't need to look at it ever again. It will be finished and operational... presently.

Reply #14 Top

Quoting Robert, reply 13
Configuring freshly built stations for auto-build...

There's nothing more annoying than an econ base that builds trade modules when there's no trade route anywhere close by. I would much rather have attack/defense modules built after the +24 production is done.

I'll bet there are some swell applications for MSAs. I don't build them, but I have seen plenty of folks complain about the drudgery involved.

I'm just about ready to try a DA game just to see what kind of planet-populator I can create. I have given up on the bonus tiles, but I am certain that I can fill up the tiles with stuff. I can at least get the manufacturing tiles since I will have to manually select a starting tile on each planet. I'll populate in the following order:

Factory, fusion, morale, lab, farm. I'll make another macro for econ structures after upgrading to Industrial Sector.

Reply #15 Top

Very helpful, this. I created 8 macros, so I can click on a fleet, select a ship, and use a hot key to upgrade to one of the eight ships in the upgrade list. I will eventually create a macro to upgrade every ship in a fleet, but right the 8 macros I created are saving a lot of time.

Reply #16 Top

Quoting Snarkotamus, reply 14
I have given up on the bonus tiles, but I am certain that I can fill up the tiles with stuff. I can at least get the manufacturing tiles since I will have to manually select a starting tile on each planet.
You can create a hotkey that reads the mouse position and builds a predetermined factory on that tile.

It will look a bit bulky but it won't be if you increase the mouse speed. (You can still watch it at the default speed)

Then you only need the mouse to move across the planet map while hitting your keys for "factory here", "morale here"...

Reply #17 Top

Quoting Snarkotamus, reply 14
I have given up on the bonus tiles

Given up on recognizing bonus tile icons? Too small or color pixels?  I haven't tried yet, could save a lot ot time.  I view this the key to string build planets.

DA, eh.  May the map gods grant you 750 planets....and 12 mil resources.

 

Reply #18 Top

I have remapped numpad / and * to TAB and SPACE respectively.  Very handy if you use the mouse with your left hand and find it awkward to reach those keys.  Plus, this puts 'find ship' and 'skip moves' functions in the same area as the movement keys and an Enter key (to end turn).

Reply #19 Top

12 mil...yikes!

Kzinti empire2.JPG Sentient species taste better...

Reply #21 Top

Just bookmarking this thread, as the forums search-function is apparently non-functional...