DoctorGibbs' Perl Toolkit for Interacting with the There World

Part 1. Introduction and Prerequisities

So, why would you want to do this?

Well, if you're a true computer geek, then you never want to do anything by hand when you could instead have a Perl script do it for you! (If this applies to you, you know who you are...)

You've got your There window. And, right next to it, you've got your Perl window -- a plain text command window that looks like a glass teletype from 1970. What might you want to do if you could make them interact?

  • Get information about where you are.
  • Walk your avatar around under program control.
  • Put conversation into your avatar's chat bubble.
  • Play back a script combining motion, emotes, words (a super macro).
  • Teleport somewhere.
  • Make your vehicle auto-navigate to somewhere and then stop.
  • Get information about objects around you.
  • Collect teleportable destinations.
  • Read signs when you are hundreds of meters away.
  • Find out who owns objects.
  • Get profile information about other avatars around you.
  • You could harvest screen names -- but DON'T: it violates There's TOS.
  • Log on, or off, There.
  • Automate any There menu commands, or sequences of commands.
  • Whatever! "Whatever" is just the reason that this series of articles is presented as a toolkit, not as a finished Perl package. I don't think that I can imagine all the things that you might want to do. Give a man a fish ... teach a man to fish. You can easily play with the code fragments given, modify them, and do ... whatever!

    Prerequisites

    1. You need to know how to program in Perl, at least a little. These pages are not a good way to learn.

    2. You need Perl installed on your Windows machine. I am using ActiveState ActivePerl 5.8.3, You can get it, free, here. If you are using a version earlier than 5.8, you won't be able to do teleports or profile lookups -- or at any rate I can't help you!.

    3. You need four add-in packages/patches to be installed into your Perl directory. Let's discuss each of these now.

    LWP is the World Wide Web Library for Perl. This installs automatically along with ActivePerl 5.8. You'll need at least version 5.68. You can determine your LWP version with this Perl script:

    use LWP;
    print "This is LWP version $LWP::VERSION\n";
    To use LWP in your scripts, put these lines at the beginning of every script using this toolkit:
    require LWP::UserAgent;
    $ua = LWP::UserAgent->new;
    
    (Note that I am reserving the variable $ua for use throughout the toolkit. Don't use it for anything else.)

    Win32::GuiTest is a very nice package for interacting with a GUI, written by Dennis K. Paulson. Here is its documentation. It is definitely not automatically installed with ActivePerl, so you need to install it, either downloading it from CPAN, or else using the Perl Package Manager (PPM) that installs with ActivePerl: Start up PPM and at the PPM> prompt, type install Win32-GuiTest. That should do it.

    Now put

    use Win32::GuiTest;
    
    near the beginning of your script.

    Next, you'll need Aldo Calpini's Win32::API. This gives low-level access to, you guessed it, the Win32 API. I found that I needed this to simulate low level key down and key up keyboard commands, and for low-level timing. Documentation is in CPAN, and as above you can either download it or else use PPM to install it (PPM> install Win32-API).

    The invocation at the beginning of every script is

    use Win32::API;
    $key = new Win32::API("user32","keybd_event",'IINP','V');
    $sleep = new Win32::API("kernel32","Sleep",'N','V');
    
    Yeah, I apologize for using $key and $sleep as reserved variables in the toolkit, but you can change them if you feel so moved. (Programming standards have just gone to pot these days, haven't they!)

    Finally, you'll need the patch to LWP that allow retrieval of SSL secure web pages (HTTPS method). I think this patch is authored by Johnny Lee, but I am not certain. You can find it here, or mirrored here. If you already have OpenSSL/Crypt::SSLeay working on your Windows machine, you can use it instead, but I find it much harder (maybe impossible?) to install. The nice thing about the Johnny Lee (?) patch is that it makes use of the SSL API already present in all recent Windows versions.

    If you don't install an SSL patch, you'll be able to do some of the stuff in later sections, but not the really good stuff!

    So now we are ready to actually do something.

    Next: Part 2