et alii*Step V.2
Monday, February 07, 2005
 

"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.

 
Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home
This blog is a combination "personal musings" (mostly satirical and dripping with sarcasm) ranging from what's going on in my life to my views on politics and various current events. For 2010 my goal is to make an entry every day for the entire year or at least as close as I can come to that goal as may be practical.

Archives
04/01/2003 - 05/01/2003 / 05/01/2003 - 06/01/2003 / 06/01/2003 - 07/01/2003 / 07/01/2003 - 08/01/2003 / 08/01/2003 - 09/01/2003 / 09/01/2003 - 10/01/2003 / 10/01/2003 - 11/01/2003 / 11/01/2003 - 12/01/2003 / 12/01/2003 - 01/01/2004 / 01/01/2004 - 02/01/2004 / 02/01/2004 - 03/01/2004 / 03/01/2004 - 04/01/2004 / 04/01/2004 - 05/01/2004 / 05/01/2004 - 06/01/2004 / 06/01/2004 - 07/01/2004 / 07/01/2004 - 08/01/2004 / 08/01/2004 - 09/01/2004 / 09/01/2004 - 10/01/2004 / 10/01/2004 - 11/01/2004 / 11/01/2004 - 12/01/2004 / 12/01/2004 - 01/01/2005 / 01/01/2005 - 02/01/2005 / 02/01/2005 - 03/01/2005 / 04/01/2005 - 05/01/2005 / 05/01/2005 - 06/01/2005 / 06/01/2005 - 07/01/2005 / 07/01/2005 - 08/01/2005 / 08/01/2005 - 09/01/2005 / 10/01/2005 - 11/01/2005 / 01/01/2006 - 02/01/2006 / 02/01/2006 - 03/01/2006 / 03/01/2006 - 04/01/2006 / 06/01/2006 - 07/01/2006 / 07/01/2006 - 08/01/2006 / 09/01/2006 - 10/01/2006 / 03/01/2007 - 04/01/2007 / 04/01/2007 - 05/01/2007 / 05/01/2007 - 06/01/2007 / 07/01/2007 - 08/01/2007 / 08/01/2007 - 09/01/2007 / 09/01/2007 - 10/01/2007 / 10/01/2007 - 11/01/2007 / 06/01/2008 - 07/01/2008 / 10/01/2008 - 11/01/2008 / 02/01/2009 - 03/01/2009 / 07/01/2009 - 08/01/2009 / 08/01/2009 - 09/01/2009 / 09/01/2009 - 10/01/2009 / 10/01/2009 - 11/01/2009 / 11/01/2009 - 12/01/2009 / 01/01/2010 - 02/01/2010 / 02/01/2010 - 03/01/2010 /


Powered by Blogger

Subscribe to
Posts [Atom]

MicroSD to MS adapter