#!/usr/bin/perl # demonstration of interfaces between Perl and There # using DoctorGibbs' TherePerl toolkit require 'TherePerlGlobals.pl'; require 'TherePerlSubs.pl'; do { print "Enter which test you want to try, between 1 and 11: "; $_ = <>; } until ( m/^\s*([0-9]+)\s*/ && ($1 > 0) && ($1 < 12)); $testno = $1; if ($testno == 1) { print "Testing whether you can GET https pages.\n"; $req = HTTP::Request->new('GET', "https://xnumrec.merchantquest.net/"); $res = $ua->request($req); if ($res->content =~ m/We feel your pain/) { print "Success!\n"; } else { print "Failed. You need to install the HTTPS patch into LWP.\n"; } } if ($testno == 2) { print "Find There window, take focus, and send SHIFT-CTRL-L.\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} print "There Window is $therewin\n"; Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); } if ($testno == 3) { print "Make your avatar sing and dance.\n"; Win32::GuiTest::SetForegroundWindow(&GetThereWindow()); Win32::GuiTest::SendKeys("Hello!~I'm your friendly avatar!~"); Win32::GuiTest::SendKeys("\'heyhey\'~"); Win32::GuiTest::SendKeys("{PAUSE 6000}"); Win32::GuiTest::SendKeys("~~~"); } if ($testno == 4) { print "Walk, run, and turn.\n"; Win32::GuiTest::SetForegroundWindow(&GetThereWindow()); &StepAvatar(12); &SendTimedArrow("D",100,100); # in case of cruise control &TurnLeftAvatar(); &RunAvatar(50); &SendTimedArrow("D",100,3000); &StepBackAvatar(5); &SendTimedArrow("D",100,100); &TurnRightAvatar(); } if ($testno == 5) { print "Get my doid, my location, and start running to Marooned.\n"; print "You'll have to vigorously interrupt the script to stop!\n"; print "Try using left and right arrow keys to perturb the course.\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); $mydoid = &GetPilotDoid(); print "My doid is $mydoid.\n"; ($x,$y,$z,$head,$alt) = &GetThobLocation($mydoid); print "I am at ($x,$y,$z), heading $head, altitude $alt.\n"; # break into a run (see RunAvatar to understand) $key->Call(0x26, 0x45, 0x01, 0); $sleep->Call(100); $key->Call(0x26, 0x45, 0x03, 0); $sleep->Call(100); $key->Call(0x26, 0x45, 0x01, 0); $sleep->Call(100); $key->Call(0x26, 0x45, 0x03, 0); $sleep->Call(100); $key->Call(0x26, 0x45, 0x01, 0); ($xto,$yto) = (2500,10200); do {$dist = &SteerToLocation($mydoid,$therewin,$xto,$yto);} until ($dist < 50); &StopMe(); } if ($testno == 6) { print "Teleport to 3rd from bottom on your Favorite Places menu\n"; print "by simulating mouse clicks on the main menu.\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &TeleportToFavorite($therewin,3); } if ($testno == 7) { print "Teleport to Island Tours East (if you have it as a favorite\n"; print "place) else return the error code.\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); sleep 1; $errcode = &MainMenuChoice(("Places", "Go To Favorite", "Island Tours East")); if ($errcode) {print "Error $errcode in teleporting.\n";} } if ($testno == 8) { print "Use WPTC interface to teleport to Duda Beach.\n"; print "(This may take up to a minute.)\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); sleep 1; $errcode = &TeleportToPlace("Duda Beach"); if ($errcode) {print "Error $errcode in teleporting.\n";} } if ($testno == 9) { print "Use WPTC interface to teleport to the ISS (by doid).\n"; print "(This may take up to a minute.)\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); sleep 1; $errcode = &TeleportToDoid("237466944"); if ($errcode) {print "Error $errcode in teleporting.\n";} } if ($testno == 10) { print "Print info on teleport destinations in your vicinity.\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); sleep 1; @urls = &GetThobDetailURLs(); &PrintTeleportableDOIDs(@urls); } if ($testno == 11) { print "Print info on avatars in your vicinity.\n"; print "(This may take a while to find each profile.)\n"; $therewin = &GetThereWindow(); if (! $therewin) {die "No There window found.";} Win32::GuiTest::SetForegroundWindow($therewin); &SendShiftCtrlL($therewin); sleep 1; @urls = &GetThobDetailURLs(); &PrintDOIDdetails(@urls); } exit(0); #END MAIN