Wednesday, May 11, 2016

AutoIt: building in the Inform IDE automatically on Windows

You don't have to know much about AutoIt to do this, but I've found this helpful. You can just create a script like the following in notepad. I called the file ide.au3.

Local $project = "Compound";

if $CmdLine[0] > 0 Then
  $project = $CmdLine[1];
  if $CmdLine[1] == "pc" Then
    $project = "Compound";
  if $CmdLine[1] == "3d" Then
    $project = "threediopolis";
  if $CmdLine[1] == "4d" Then
    $project = "fourdiopolis";

run("C:\\Program Files (x86)\\Inform 7\\Inform7.exe");

WinWaitActive("Welcome to Inform 7");


WinWaitActive("Open a project");

Send("c:\games\inform\" & $project & ".inform!O");

WinWaitActive($project & ".inform - Inform");

This will open up a project and compile it. You may want to change the c:\games\inform directory, or the project name, but I hope the code makes intuitive sense. The CmdLine stuff basically says I could try ide.au3 threediopolis or ide.au3 fourdiopolis or, better yet, theshortcut ide.au3 3d, if I wanted. Awkward code, but I'm too lazy to read if hashes are a Thing in AutoIt, and what I have works.

It's handy for me as it'd be nice to be the first thing to see in the morning, so I do that instead of silly internet browsing. Or if you edit outside the IDE (I use notepad++), pushing the button here can work.

You can obviously tweak this to check for if a window is already open, but this basic script says: build every night, and have the IDE open when you get started.

A script like this may not be profound in itself, but it certainly starts things right. Now I've done it, I feel like I should have a few years ago. These things seem like they only save a few seconds, but when they're more convenient than accessing a time wasting website, they can save a lot more time.

(Note: this was updated for ide.au3 to allow a command line argument as well as shortcut text)

No comments:

Post a Comment