--------------------------------------------------------------------------
detect.dll 1.0 beta 4                                     //--ruhmkorff--//      
--------------------------------------------------------------------------
Based on LSMail by MrJukes, Vendicator, Jesus_mjjg and ilmcuts.
__________________________________________________________________________

This Litestep module retrieves drive informations as well as internet connection status info
in form of LS-evars, using an internal timer function. It can be used to auto-hide drive-shortcuts, 
auto-display CD- and DVD-titles, auto-hide LSMail or even create an autoplay-on-insert function for single CD/DVDs and much more.

This module is made mainly for scripting i.e it has a skinnable window, but this window only
hosts a small popup-menu for some basic functions. I recommend to use it hidden. A solution 
without window would be preferable, but, as far as I know, the cpu-friendly "OnTimer" 
function requires at least a pseudowindow. So be it ;). Possibly, the window will get more 
functionality in later versions.
You'll need a Litestep version that supports runtime-setting of $evars$. 
A version of wininet.dll (IE 4+) is required for net-check. 

Detect sets following evars (where X = drive letter without ":" and "\"):

$DriveTypeX$
$DriveNameX$
$DriveFSX$
$DriveSerialX$
$DetectFlag$
$Connection$
$ConType$
$ConRAS$
$Monitors$
$Display0Name$
$Display0Device$



$DriveTypeX$    ->   type of volume $DriveType$ = HardDrive,Removable,CD/DVD,NetDrive
                     or RamDisk;
                ->   if X = unknown, $DriveTypeX$ = unknown
                ->   if X = no root directory found, $DriveTypeX$ = NoDrive 
                       (= when CDROM-, Floppy-Drive a.s.o. empty)
$DriveNameX$    ->   title of volume
                ->   if no volume title $DriveNameX$ = HardDrive_NoTitle,
                     Removable_NoTitle, CD/DVD_NoTitle NetDrive_NoTitle, 
                     RamDisk_NoTitle
                ->   if X = unknown, $DriveNameX$ = unknown
                ->   if X = no root directory found, $DriveNameX$ = NoDrive
$DriveFSX$      ->   file system of volume
                ->   if X = unknown, $DriveFSX$ = NotAvailable
                ->   if X = no root directory found, $DriveFSX$ = NotAvailable
$DriveSerialX$  ->   volume serial number
                ->   if X = unknown, $DriveSerialX$ = 0
                ->   if X = no root directory found, $DriveSerialX$ = 0
$Connection$    ->   $Connection$ = connected if connected (IE4) or name of connection (IE5+)
                     The name of connection should be suitable for evars i.e no blanks and less 
                     than 64 characters.
                ->   $Connection$ = NotAvailable if unable to check connection (IE3, a.s.o)
                ->   $ConType$ = LAN or Modem (if connected)
                ->   $ConRAS$ = RAS or NoRAS
                ->   if not connected, $Connection$ = NoConnection
$DetectFlag$    ->   true or false (as text), depending if a change in the configuration has
                     occured since last check.
$Monitors$      ->   number of available monitors.
$DisplayXName$  ->   System name of display (X = numbers starting with 0)
                     f.e //./DISPLAY1
$DisplayXDevice$->   device of display (X = numbers starting with 0)
                     f.e Ati-Radeon-XX or Nvidia-Riva-XX.

Use the !alert bang to view them.            

After every check, the command specified by DetectCmd is triggered
for getting an update of your lables or whatever. You can use the DetectFlag
to make commands depending on change.
Please consider that the variables are only available after the first check. If you
use them earlier, you'll get a MessageBox (case you didn't define default evars in step.rc).

Bangs:

!DetectCheck                          -> checks drives and net (even if DetectDisableCheck = true !)
!DetectHide/!DetectShow/!DetectToggle -> visibility
!DetectMove <x> <y>                   -> change position
!DetectSetVar <evar> <value>          -> set any evar by bang
!DetectHook                           -> for LSBox
!DetectCheckDisplay                   -> check display (Monitors), is always done at startup
!DetectFloppy                         -> Floppy is only checked once automatically,
                                         use this bang if you like to check once again.
                                         There is a dummy-entry set for floppy if "A" is
                                         included in "DetectCheckDrives" with the settings and detected
                                         at module start:
                                         $DriveNameA$ = Floppy-A
                                         $DriveTypeA$ = Floppy
                                         $DriveFSA$ = FAT
                                         $DriveSerialA$ = 0
!DetectEject <DriveLetter> <flag>     -> eject/retract drive flag == 1 -> eject
                                                             flag == 0 -> retract
                                         This function has not been safety-tested for all kinds of drives. Use with care. 
!DetectPopup <x> <y>                  -> Show the popup-menu at position (top + !! right point)
                                         x y (a drive check is performed before to update it)


Settings:

DetectTimer <number>                  -> drive-check time interval in seconds
                                         10 seconds work fine.

DetectX <number>
DetectY <number>
DetectW <number>
DetectH <number>
DetectBackBmp <path>                  -> png or bmp
DetectNotificationBmp <path>          -> shown when a change in drive configuration was detected
                                         visible for the time specified in DetectTimer
DetectCmd <command>                   -> bang to be executed after checking
DetectCheckDrives <letters>           -> what drives to check (without ":" and "\"), f.e "ACDEXZ", default "CDE"
DetectBackColor <color>
DetectErrorBackColor <color>
DetectStartHidden <true/false> 
DetectAlwaysOnTop <true/false>
DetectDisableCheck <true/false>       -> disable timer triggered checking for drives
DetectNoNetCheck <true/false>         -> disable timer triggerd checking for net, i.e.
                                         it is checked only once at module loading time and 
                                         by manual bang.
DetectMakePretty <true/false>         -> makes $DriveNameX$ looking nicer by usage of 
                                         upper- and lowercase characters and changing "_" to "-". 

A (mz)script may look like this:

        DetectCmd !update

        *Script bang !update
        *Script exec !varset labela %#DetectFlag%#
        *Script gotoif ("%{labela}" = "false") skipp  //Only do anything if something got changed
        *Script exec !varset titlevar %#DriveNameE%#
        *Script exec |LabelSetText labele %[titlevar]
        *Script exec !ifEq titlevar "NoDrive" '|LabelHide labele' else '|LabelShow labele'
        *Script label skipp
        *Script ~bang

Known issues:

Sorry folks, but this module was made on a tiny laptop, while beeing completely 
encircled by Macs.

It is only tested on XP (actually I couldnt even test it on an other computer), and I had also no opportunity to test net-drives, ramdisks, many drives a.s.o. It is a true beta. 
Reports are welcome. 
Nothing dangerous should happen, the module simply utilizes the InternetGetConnectedState(Ex), GetDriveType and GetVolumeInfo WinApi-functions.
Sources will come with 1.0.

Have fun !

Please contact me at ruhmkorff@coolkiwi.com for bug reports, ideas and comments.

Changes:

beta 4..
..Corrected permanent floppy access bug. Sorry for that.
..Added monitor information.
..Added drive eject bang.
..Added popup menu activation by bang.
..Changed from errorbmp to notification of changes.
..All connection evars set to "NoConnection" if no connection is detected instead of not setting them at all.

beta 3..
..LSBox hooking fixed.
..Message handling fixed (refresh, revid).
..better menu handling.
..detectflag for changes fixed.
..added DetectMakePretty for drivenames.

beta 2..
..Modernized the module according to newer standards (SafeString not included yet).
..Made the popup menu a little smarter. Drives can be accessed via a submenu if present.
..Did some general code cleanup.
Still needs a some serious work, but I am learning.... 




