(view source code of canonrep.vbs as plain text)
Option Explicit
Dim blnTimedOut, i, intTimeOut, objIE, objRE, strHTML, strIP, strMsg, strURL
If WScript.Arguments.Unnamed.Count <> 1 Then Syntax
If WScript.Arguments.Named.Count > 0 Then Syntax
strIP = WScript.Arguments.Item(0)
strURL = "http://" & strIP & "/en/pages/d_cbody.htm"
strMsg = ""
intTimeOut = 30
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Visible = False
objIE.Navigate2 strURL
' Wait till IE is ready
i = 0
blnTimedOut = False
Do While objIE.Busy
WScript.Sleep 100
i = i + 1
' Time out after the specified number of seconds
If i > CInt( intTimeOut * 10 ) Then
blnTimedOut = True
Exit Do
End If
Loop
' Retrieve the URL's text and save it in an array
If Not blnTimedOut Then
strHTML = objIE.Document.Body.InnerHTML
End If
Set objRE = New RegExp
objRE.Global = False
objRE.IgnoreCase = True
objRE.Pattern = ">write_value\(\""(101)\"", (\d+)\);<(\n|.)+>write_value\(\""(103)\"", (\d+)\);<(\n|.)+>write_value\(\""(104)\"", (\d+)\);<"
Set objMatch = objRE.Execute( strHTML )
If objMatch.Count = 1 Then
strMsg = strIP & vbCrLf _
& objMatch.Item(0).Submatches(0) & vbTab & "Total1" & vbTab & objMatch.Item(0).Submatches(1) & vbCrLf _
& objMatch.Item(0).Submatches(3) & vbTab & "Total (Large)" & vbTab & objMatch.Item(0).Submatches(4) & vbCrLf _
& objMatch.Item(0).Submatches(6) & vbTab & "Total (Small)" & vbTab & objMatch.Item(0).Submatches(7) & vbCrLf
WScript.Echo strMsg
End If
objIE.Quit
Set objIE = Nothing
Set objMatch = Nothing
Set objRE = Nothing
Sub Syntax
strMsg = vbCrLf _
& "CanonReport.vbs, Version 1.01" _
& vbCrLf _
& "Display Canon IR3320 printers' total print output" _
& vbCrLf _
& "(may or may not work on other Canon printer models)" _
& vbCrLf & vbCrLf _
& "Usage: CSCRIPT.EXE //NoLogo CANONREP.VBS ip_address" _
& vbCrLf & vbCrLf _
& "Where: ""ip_address"" is the IP address of the printer" _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit 1
End Sub
page last modified: 2024-04-16; loaded in 0.0088 seconds