Random Thoughts of a Scatterbrain.
 Tuesday, October 10, 2006

Self Reminder

10/10/2006 7:54:04 PM (Eastern Daylight Time, UTC-04:00)

I've been meaning to put together a series of articles on how to build a system to support software automation (where automation is not supported natively) after completing what I would say is my most significant project of my career a few months ago (it was indeed, quite awesome to see in action.

What's the motivation for this? There are somethings that you simply cannot do via APIs that require automation of the UI. For example, what if you want to write an engine that will browse a site list and grab screenshots of the pages? What if you need to generate content on the server in Excel, Word, or PowerPoint (pre-2007)? What if you need to adjust and auto-publish a large number of project plans in Microsoft Project Professional?

These types of actions require an automation engine and a supporting framework to allow for manipulation of the UI and some clever tricks to take care of the exceptional cases since they were written to be used in interactive sessions. While I obviously cannot release any of the code I wrote previously line for line, I would like to discuss the strategies and some code snippets and use new code to cover this topic which I found to be lacking when I myself was searching for a way to do this.

As a summary, I think I'm going to break it down into a few chapters:

  • An Introduction: Automating Internet Explorer. As an example, we'll start by looking at the foundation of automating any of the Windows applications using .Net.  The ideas here apply not only to IE, but to almost any Windows application that exposes an API.
  • Simulating User Input. We'll continue the example by examining how to deal with cases where the application is expecting user input.  If so inclined, we could disregard the API completely and simply use this methodology throughout.
  • UI Mapped Input Sequences. We'll discuss how to take the example a bit further by examining how to trap UI elements and send the proper key sequences to handle them.

I think this will be a great series (once I actually get around to putting it together) as it will cover a whole host of technologies from Spring.Net to log4net to Enterprise Library.

 Thursday, February 23, 2006

WinFX February CTP

2/23/2006 10:23:55 AM (Eastern Standard Time, UTC-05:00)

This is definitely something I'm going to have to download and play around with in the next few weeks.

 Friday, September 30, 2005

DHTML Games

9/30/2005 8:55:21 AM (Eastern Daylight Time, UTC-04:00)

Finally figured out how to fix some of the bugs and problems I had with jsTetris last night as I was laying down to sleep (I hate that).

Each list element needs to have a property, State, which takes one of two values:

  • 0 when the list element is empty (no pieces in it) or the list element is holding an active block (a block that can still move).
  • 1 when the list element is holding a fixed block (a block that can no longer move).

One of the big problems I had previously was that it was difficult to calculate when a piece could still move.  The method I was using was too inefficient and took too many lines of code.  It tried to examine each of the target blocks to see if it contained an inactive block.  This should make it easier by performing some simple math instead.

Each block of each piece must be examined in the direction of the move and simply do a sum between each block and the list element in the target block.  If the sum of the State is 0, then we can move the block.  If the sum is anything other than 0, then the block cannot be moved anymore.

Once a block stops moving, before the next buffered piece is moved (may have to cancel timer), we sum across the bottom most row up 4 rows and see if the sum in that row divided by the number of columns is exactly 1.  If so, this means that every list element in that row is holding a fixed block and we can move get rid of that row.  Once we've checked 4 rows, we can then move all of the remaining straggling pieces down before reactivating the timer on the buffered piece.

Seems like a plan.

I was also thinking about doing two other games last night. 

One of them would be based off of pipe dreams.  Remember that game where you have to move around blocks which contained pipes as this green ooze started flowing?  I think it can be done with .gif animations if each of the animations takes precisely the same amount of time.  There are a total of 7 different pieces.  6 of those pieces would need two sets of animations and one of them, a cross shaped piece, would need 4 animations.  This brings the total number of pieces up to 16.  The idea would be to cache each of these images and swap them out as the flow of the ooze moves through the pipes.  This one should be interesting.

The other game would be based off of a game that I had on my TI-83 back in my highschool days which is kind of along the lines of Dr. Mario or Tetris Attack, except without falling pieces.  Basically, you get a random m*n board, which is completely filled with pieces (maybe 5-6 different types).  When you have three or more adjacent pieces, those pieces disappear.  And "loose" pieces fall into the space left by those pieces and can cause "combos".  The objective is to clear the entire board with as high a score as possible (factoring in time and combos).  Like Tetris Attack (I don't completely remember the mechanics of Dr. Mario), you can manipulate two adjacent blocks in the grid at a time.

Neither of these seem too difficult and sound like fun.

Oh yeah, I'm also working on a ASP.Net Beta 2 based version of Chinese chess or Xiangqi.  The idea is to use Atlas to allow two players to play in real time, with the moves and chat being relayed using calls to web services from the client.  So far, I have the board and objects laid out.  I still have to figure out how I want to implement the game rules and how complex to make it in terms of supporting multiple games at once.  I'm also waiting for my Beta 2 hosting account from ServerIntellect, my webhost.

That's it for now.

RSS 2.0 Atom 1.0 CDF