"Fun with Scripting"
Ok Seems I've been doing a lot of ignoring of this blog. I started playing Morrowind again and it's pretty fun. Also I found this new macro/scripting language that's insanely easy yet really powerful called
AutoHotKey. I originally found it while looking for something to make typing in names of cities and people from Morrowind into a new Morrowind-related blog I started a little easier (for instance cc and a space types in Caius Cosades auto-magically for me). Soon I found it can do a lot more than just that. So I wrote a script that makes sure I'm in Morrowind and then sends the hotkey for "autosave", repeating this every five minutes.
I have almost as much fun with scripting that as I do actually playing the game. Anyone looking to learn programming I highly recommend it. I wonder if AppleScript can do something like that. I should ask stupid questions like that!
I know "windows script host" can do that already, albeit with a lot more lines of code. AutoHotKey will just look for a window with a particular title in the title bar as well as the "class ID" or "window ID" while window script host only goes by an ID and you have to put in a way to find which window. A good step of course but does slow down the development process.
Here, have my morrowind script:
; *** Start morrowind auto-save script here ***
; *** you must install autohotkey to make this work
; Glitch: the SetTitleMatchMode line tells the script to find a window that says
; "morrowind" and ONLY morrowind however start another window that somehow has
; morrowind only in it and this script may act on that one.
; Of course if you play in full-screen that might not be much of an issue.
SetTitleMatchMode, 3 ; match *exactly* Morrowind
IfWinNotExist, Morrowind
{
MsgBox, 4, Morrowind?, Open Morrowind to play?
IfMsgBox, No
{
Return
}
; adjust game path to your own
Run, G:\Program Files\Bethesda Softworks\Morrowind\Morrowind Launcher.exe, G:\Program Files\Bethesda Softworks\Morrowind
}
Sleep, 120000 ; lets wait 2 minutes for the user to load morrowind and the save game (comment to skip)
loop ; normally infinite loops are bad...
{
IfWinNotExist, Morrowind
{
return ; but this one auto-exits after it finds no morrowind window
}
IfWinExist, Morrowind
{
IfWinActive, Morrowind
{ ; the first number in the below line is time in ms.
; how long between each auto-save in other words
; 300000 translates to 5 minutes by my calculations (5 * 60 * 1000)
; the second number is how long the key pressed
; according to the autohotkey FAQ that's a necessary entry with some DirectX games.
SetKeyDelay, 300000,20
Send, {F5}
}
}
}
; *** End morrowind auto-save script here ***
What a weak blog entry. It'll have to do.