Internet Fishtank
Nothing exemplifies the power of the Internet more than an Internetenabled
fishtank. This, essentially, is a web page with a dynamic picture of
the contents of a fishtank. There are several ways to do this, but the following
shows that it can be done with nothing more than a script, a webcam,*
and a common FTP account.
These listings assume that the camera program and all images it creates are
stored in the folder C:\camera. Start with the script shown in Example 9-3.
* See ???Add Wireless Support to Any Device,??? in Chapter 7, for information on wireless webcams.
Wacky Script Ideas | 549
Scripting and
Automation
The script starts by suppressing all error messages, as described in the previous
example. The subsequent lines use the snapshot utility that comes with
nearly all cheap webcams to snap a still photo and save it to a .jpg image file.
Note also the line that deletes the old file before the photo is taken, and the
line thereafter that checks for the existence of the file before proceeding (in
case something went wrong); this way, the script never sends the same
photo twice. The inclusion of True in the RunProgram line instructs the script
to wait for the camera.exe program to complete before the script continues,
necessary for a script like this to work. You could alternatively incorporate a
Do...Loop loop instead of the simple If statement to repeatedly check for the
file over the course of several seconds.
Pages:
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765