Thank you for your consideration.

Moderators: JRL, Dorian (MJT support)
=======================================Execute>Q:\Masters\New\Scripts\wshBlockInputDemo.vbs
=========================================' wshBlockInput.vbs, jw 19Oct01
'
' --- description block --------------------------
'
' Title: wsh Block Input Demo Script
'
' Description: wshBI provides a means of blocking
' all keyboard and mouse activity,
' while your script is running...
'
' Author: jwarrington*NoSteekinSpam*@worldnet.att.net
' Website: http://home.att.net/~wshvbs/index.htm
'
' Usage: Use at you own risk, tested on win98se...
'
' --- revision history ---------------------------
' 19Oct01: original attempt...
' --- end of description block -------------------
Option Explicit
'
' instantiate ActX components here...
' (note: using "call instantiate" to provide better info in case obj is missing)
Dim oNMD : Call Instantiate (oNMD, "wshLtWtNonModalDialog.ucNMD", "oNMD_")
Dim oATO : Call Instantiate (oATO, "wshAPIToolkitObject.ucATO", "") ' (no events)
'
'
Dim m_btnExitID ' as integer
'
Dim bCloseFlag ' t/f if user closed the form...
Dim bExitClick ' as boolean
'
Dim mnuArray ' as variant (array of menu items)
Dim sEvent ' as string
'
Const sIconPath = "c:\windows\wscript.exe" ' path to desired icon
Const sIconNr = "0" ' ordinal of icon in the above dll, exe...
'
Dim nRtn ' as long
Const m_sCaption = " > "
Const m_sLogo = "brought to you by: jawar productions. (clap, clap, clap)... "
Dim oForm ' oNMD's "form object"
Dim m_hForm
' --- end of declarations and constants ----------
' ================================================
' === MAIN LINE SCRIPT LOGIC =====================
' ================================================
' Create the Form, and add the controls...
Call Create_Form()
Set oForm = oNMD.frmDialog ' getref to form object
m_hForm = oForm.hWnd ' get form handle
' oNMD.AddLine "Form Created. (form hWnd is: " & Hex(m_hForm)
' make adjustments to form objects...
oForm.ImageBox(1).Picture = LoadPicture(GetLocalDirectory & "Dilbert.ico")
oForm.Label(2).ForeColor = vbRed
oForm.Label(3).ForeColor = vbRed
oForm.Button(1).Visible = False
With oForm.Label(5).Font
.Name = "Arial" : .Size = 7 : .Bold = False : .Italic = True
End With
oNMD.EnableCloseBtn = False ' DIS-able the close button...
Call BlockInput(True) ' block any keybd or mouse input...
oNMD.ShowDialog True ' show the form (er, dialog)...
' wait around for user cancel/close...
bCloseFlag = FALSE ' set close flag as undetected.
bExitClick = False
Dim iPctDone
For iPctDone = 1 to 100
WScript.Sleep 200 ' wait/delay (pretend script is working)...
' with BlockInput in effect, text whether any clicks getting through...
if bExitClick then Exit For
if bCloseFlag then Exit For
oNMD.PctComplete iPctDone ' advance progbar
Next ' end of "for" loop...
' finished with the script business, let the user know...
With oForm.Label(2)
.Visible = False
.Caption = "The Script is Finished. " _
& "Your Group Collaboration Software has been installed successfully. "
.Font.Size = 12 : .ForeColor = vbGreen : .Visible = True
End With
With oForm.Label(3)
.Visible = False
.Caption = "We do appreciate your patience... "
.Font.Size = 12 : .ForeColor = vbGreen : .Visible = True
End With
oNMD.EnableCloseBtn = True ' EN-able the close button...
oForm.Button(1).Visible = True
Call BlockInput(False) ' UN-BlockInput
Do
WScript.Sleep 200 ' allow for processing events...
Loop Until (bExitClick Or bCloseFlag)
Set oForm = nothing
Set oNMD = nothing ' clean up
Set oATO = nothing
WScript.Quit
' ================================================
' === SUBROUTINES FOLLOW =========================
' ================================================
' --- click event handlers ---
Sub oNMD_ButtonClick(btnID)
' MsgBox("Button Clicked, ID = " & CStr(btnID))
if btnID = m_btnExitID then bExitClick = True
End Sub
Sub oNMD_UserClose()
' MsgBox(" .. user close detected")
bCloseFlag = TRUE
End Sub
' --- this code creates the form and adds the controls ---
Sub Create_Form()
Dim wdForm, htForm, wdBtn, htBtn, wdBtnSp ' as long
' do some geometry calculations...
wdForm = 460 : htForm = 320 : wdBtn = 150 : htBtn = 25
wdBtnSp = Int((wdForm - wdBtn) / 2) - 3
oNMD.CreateDialog m_sCaption, 40,40, CLng(wdForm),CLng(htForm) ' top was 100
oNMD.AddImageBox 20,15, 32,32
oNMD.AddLabel "Hi. I'm Reginald, your over-worked (but still helpful and friendly) " _
& "SysAdmin. Today, I'm going to be installing some new Group Collaboration " _
& "Software for you. ", 70,15, 400,45
' ==============================================
' === Draw an "Etched Edge" separator ==========
' draw a home-made "etched edge" line, using vbRect and accent line,
' (Note: you started with white, but then "softened" it a bit)...
Const topSep = 65
Const vbFSSolid = 0 ' fill style constant
Const crOffWhite = &HF0F0F0
Const crDkGray = &H808080
With oNMD.frmDialog
.AutoRedraw = True ' set autoredraw (so as to "persist" the vb graphics)...
.FillColor = vbWhite ' crOffWhite ' start with white box (ht = 2pix)
.FillStyle = vbFSSolid
.vbRectangle 20,topSep, wdForm-45,2, vbWhite ' crOffWhite
.vbLine 20+1,topSep, wdForm-45-2,0, crDkGray ' vbBlack ' black accent line
End With
oNMD.AddLabel "Nota Bene: It's VERY IMPORTANT not to disturb this script while it's " _
& "running. Any interruptions could mess up this software installation, " _
& "resulting in an inoperable system. That would be extremely unfortunate " _
& "for both you and me. (Especially for me). ", 20,topSep+10, wdForm-45,60
oNMD.AddLabel "To prevent any interruptions, I have locked the keyboard and mouse " _
& "temporarily, so you can't use the system. Kindly take a short break, " _
& "enjoy a cup of coffee or a diet coke (courtesy of the IT department). " _
& "Your system will be ready to go in about two minutes... ", _
20,topSep+70, wdForm-45,60
' === Draw an "Etched Edge" separator ==========
With oNMD.frmDialog
.vbRectangle 20,topSep+130, wdForm-45,2, vbWhite ' crOffWhite
.vbLine 20+1,topSep+130, wdForm-45-2,0, crDkGray ' vbBlack ' black accent line
End With
Const htCaption = 25
Dim htClient : htClient = htForm - htCaption
oNMD.AddLabel "Script Progress Bar... ", 45,htClient-20-htBtn-25-20, 360,15
oNMD.AddProgressBar 40,htClient-20-htBtn-25, 360,20
oNMD.AddButton "Close This Dialog", wdBtnSp,htClient-15-htBtn, wdBtn,htBtn
m_btnExitID = 101 ' the first button created has an ID of 101
oNMD.AddLabel m_sLogo, 180,htClient-12, 400,15
' --- finished with creating the form ---
End Sub
' --- ADD ADVISORY EXIT MESSAGES TO THE LSTBOX ---
Sub ExitMsg (bExit, bClose)
oNMD.AddLine " " ' space down one line...
if bExit then ' test for exit/close click...
oNMD.AddLine " => User Clicked Exit, "
elseif bClose then
oNMD.AddLine " => User Clicked Close [X] Button, "
End If
oNMD.AddLine " (this window will close in 2 secs)... "
WScript.Sleep 2000
End Sub
' ================================================
' ================================================
' === "WRAPPERS" FOR API CALLS ===================
' ================================================
' ================================================
Function BlockInput(bFlag)
BlockInput = oATO.CallAPI("USER32.DLL", "BlockInput", bFlag)
End Function
' ------------------------------------------------
' --- Get Local Directory (of this script) -------
' ------------------------------------------------
' Note: when fso is instantiated, then use this:
' GetLocalDirectory = fso.GetFile(WScript.ScriptFullName).ParentFolder
'
' (however, if fso NOT instantiated, use the following code,
' it's more efficient there are NO additional ole instantiations
' required, with all that ugly and slow "late-binding")...
'
' --- other possibilities from the wsh ng, (mikHar)...
' --- wsh 5.5 ---
' set fso = createobject("scripting.filesystemobject")
' currentDirectory = fso.getabsolutepathname(".")
' --- wsh 5.6 ---
' set shell = createobject("wscript.shell")
' currentDirectory = shell.currentdirectory
' --- end of other possibilities -----------------
'
Function GetLocalDirectory()
Const sMe = "[GetLocalDirectory], "
Dim iFile ' as integer
' find the LAST backslash...
iFile = InStrRev(Wscript.ScriptFullName, "\")
BugAssert (iFile > 0), sMe & " file path problem " ' if backslash not found...
' get the path to this script...
GetLocalDirectory = Left(Wscript.ScriptFullName, iFile) ' path (inc "\")...
End Function
' ================================================
' === INSTANTIATE ACTX OBJ and BUGASSERT =========
' ================================================
' --- INSTANTIATE ACTX OBJECT (or class) AND CHECK ----
' (using a sub to get this ugly instantiation code out of main line code)...
Sub Instantiate (oObject, sProgramID, sEventPrefix)
Const sME = "[sub Instantiate], "
' check variant sub-type parameters...
BugAssert (VarType(sProgramID) = vbString), sME & "sProgramID must be a STRING!"
BugAssert (VarType(sEventPrefix) = vbString), sME & "sEventPrefix must be a STRING!"
On Error Resume Next ' turn on error checking
Set oObject = WScript.CreateObject(sProgramID, sEventPrefix)
BugAssert (err.number = 0), sME & "This script requires: " & sProgramID & vbCrlf _
& " kindly INSTALL and REGISTER this ActX component... "
On Error goto 0 ' turn off error checking...
End Sub
' --- BUGASSERT (yes, it's for debugging) --------
Sub BugAssert (bTest, sErrMsg)
Dim sDblSpace : sDblSpace = vbCrLf & vbCrLf
' BugAssert is a Bruce McKinney creation.
' It is used to test for intermediate results...
if bTest then Exit Sub ' normally (hopefully) test returns true...
MsgBox "Error Message reported by BugAssert: " & sDblSpace _
& sErrMsg & sDblSpace & " this script will terminate NOW. ", _
vbCritical, " > "
WScript.Quit
End Sub
Sub Old_Code()
End Sub