You can download all the source code for the Lightning Break Robot. Please feel free to
have a look at how it works, re-use it or adapt it for whatever you like. If you do anything
interesting with it, or improve it - please let us know.
If you look at the code, the types of things you will learn about and see examples of are:
- .NET framework 1.1
- win32 api interop
- screen grabbing
- emulating clicking
- windows forms applications
- The structure of Windows (windows within windows within windows!)
- Threading and state maintenance
- GDI+ graphics
To compile the code, you'll need a copy of Microsoft Visual Studio.
This version of the code is compiled in Visual Studio 2003, but it should be
fairly simple to upgrade if you're running a more recent version of Visual Studio.
Part 1: List Windows
||A .NET winforms application which enables you to get handles on all the windows on your Windows desktop,
and also to recurse through their nested child windows.
The application also retrieves details about the windows - such as their position, their title, and their
width and height. It uses a number of win32 interop calls and delegates.
Part 2: Lightning Break Robot
||This code is in serious need of refactoring! It has been cobbled
together quite quickly - a refactored version should be available soon.
||A C# .NET 1.1 winforms application which plays a browser based snooker game.
The application works by
screen-grabbing the browser window, working out co-ordinates of elements in the window
based on colour of pixels, calculating optimal potting angles and then playing the game
by emulating mouse clicks in the window. The application determines which ball is the target
by virtue of the fact that the game surrounds target balls with a white dashed circle.
The application makes use of win32 api interop calls to perform screen grabs and
to emulate window clicks and uses GDI+ to display information about how the
Robot is applying its logic to the game play. It uses threading to ensure that
the application window can be updated and remain functional (interuptable with a stop button)
while the robot is running.