Archives

The List

« E-mail Hosting Recommendations? | Main

I Really Need to Get a Life…

By Carsten | December 26, 2010

Poul-Henning Kamp, of FreeBSD fame, posted a year-end question (in Danish) on his blog at the IT rag version2.dk: What would be the computer equivalent of Shannon’s ultimate machine?

Based on one of the comment suggestions, inspired by the fact that I’d been messing around with automating the Windows cursor some months back, and having half an hour too much spare time, I came up with my own contender for the world’s most useless computer program:

(http://www.youtube.com/watch?v=9WTq2nRgYeQ)

If you’re intensely interested, the interesting part of the C# program is here:

using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;

namespace Shannon {
public partial class Shannon : Form {
[DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags {
MOVE = 0×1,
LEFTDOWN = 0×2,
LEFTUP = 0×4,
}

public Shannon() {
InitializeComponent();
}

// In order to show what’s going on, we don’t do any work until the
// program has settled down.
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
Application.Idle += new EventHandler(OnLoaded);
}

private void OnLoaded(object sender, EventArgs e) {
Application.Idle -= new EventHandler(OnLoaded);
// form is centered on a 1600×1200 screen
Cursor.Position = new Point(790, 575);
Thread.Sleep(500);
for (int i = 0; i < 135; i++) {
mouse_event((int)(MouseEventFlags.MOVE), 1, -1, 0, 0);
Thread.Sleep(20);
}
Thread.Sleep(150);
mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);
}
}
}

Topics: MySQL |

One Response to “I Really Need to Get a Life…”

  1. Dave Stokes Says:
    December 26th, 2010 at 6:32 pm

    At my university, we had a professor who taught object classes in Pascal of similar usefulness but it took two semesters and a few grad students :-) Happy Holidays Carsten to you and your family?

Comments