Re: Announcing Interactive JScript

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 9 Feb 2008 07:38:03 -0500 (EST)

Hi Richard,
If the new Window-Eyes scripting capability truly supports any language
that can do COM automation, then Interactive JScript should work as a tool
for developing scripts.  Reflection is a notable feature.  Once the
included tlbinf32.dll file is registered (explained in the documentation),
you can get a list of all methods and properties of a COM object.  For
example, suppose you want to explore the Internet Explorer object model,
you could enter the following commands:

oIE = Interaction.CreateObject("InternetExplorer.Application")
dir oIE

The list does not provide documentation on each object member (like
Python can), but it does provide their names and parameters.  You can
often guess what a method does by its name, or at least use it as a Google
term for more information.  If you want to save any part of a session to a
file, enter a command like the following:

log c:\temp\test.txt

To further illustrate this interactive approach, suppose you wanted to
get the text of the front page of BlindProgramming.com:

oIE = Interaction.CreateObject("InternetExplorer.Application")
oIE.Navigate("http://BlindProgramming.com";)
oDoc = oIE.Document
oBody = oDoc.body
oRange = oBody.CreateTextRange()
sText = oRange.Text

After each command, Interactive JScript will output a string
representation of its result, if any.  For example, a command that
creates a new COM object outputs the ToString() value of that object,
which is
System.__ComObject

If you do not hear any output, there was probably an error, so recheck the
syntax.  Although JScript is quite a friendly scripting language, one
potential gotcha is that it is case-sensitive.  I found, for example, that
some of the IE properties or methods begin with a lowercase rather than
uppercase letter, which made the difference in whether they worked.

The dir command also works for .NET objects (by the .NET reflection
API).  In that case, you can seperately list constructors, methods,
properties, and events using those command names instead of dir before
the name of the variable that refers to the object.

Since this is a 1.0 version, there are probably some rough edges, so
definately let me know, and I'll do whatever I can to improve it.

By the way, I recall that you asked about learning COM programming.
Since you know how to program in VB .NET, you already know COM
programming syntax.  Basically, it is just another way of creating an
object, but then methods and properties are used in the same way as a .NET
object.

Jamal
 On Sat, 9 Feb 2008, Richard Thomas wrote:

> Date: Sat, 9 Feb 2008 05:55:57 -0500
> From: Richard Thomas <rthomas@xxxxxxxxxxx>
> Reply-To: programmingblind@xxxxxxxxxxxxx
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: Announcing Interactive JScript
>
> Hi Jamal:
> Could be this will help if I write some Scripts for WindowEyes if I read it
> right.  Not sure if I will work in Managed Code or a scripting language yet
> but if scripting it might be helpful, not sure as I've not done any
> scripting and have had bad luck at the command line with WindowEyes so far,
> note I've only lightly tried command line a few times and given up.
> Rick Farmington Mich. USA
> ----- Original Message -----
> From: "tribble" <lauraeaves@xxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Friday, February 08, 2008 10:58 AM
> Subject: Re: Announcing Interactive JScript
>
>
> > Hi Jamal -- well thanks for the compliment -- but I thought your
> > interpreter
> > was a well chosen project, in which you took what was already out there
> > and
> > apparently got it working with features useful for blind developers.  I
> > haven't seen the code or tried it out as yet, but given your track record
> > I'm sure it is a good piece of work.  I mention the selection of project
> > and
> > selection of code base as I in times past  made the mistake of diving into
> > something without first checking or considering what was already out
> > there.
> > So that shows you have business sense as well as tech savvy.
> > --le
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Jamal Mazrui" <empower@xxxxxxxxx>
> > To: <programmingblind@xxxxxxxxxxxxx>
> > Sent: Friday, February 08, 2008 5:57 AM
> > Subject: Re: Announcing Interactive JScript
> >
> >
> > Thanks, Laura -- with your background, that's particularly meaningful!
> > Jamal
> > On Thu, 7 Feb 2008, tribble wrote:
> >
> >> Date: Thu, 7 Feb 2008 12:04:28 -0500
> >> From: tribble <lauraeaves@xxxxxxxxx>
> >> Reply-To: programmingblind@xxxxxxxxxxxxx
> >> To: programmingblind@xxxxxxxxxxxxx
> >> Subject: Re: Announcing Interactive JScript
> >>
> >> Cool -- sounds quite useful -- great job
> >>
> >> ----- Original Message -----
> >> From: "Jamal Mazrui" <empower@xxxxxxxxx>
> >> To: <programmingblind@xxxxxxxxxxxxx>; <program-l@xxxxxxxxxxxxx>;
> >> <guispeak@xxxxxxxxxxxxx>
> >> Sent: Thursday, February 07, 2008 7:13 AM
> >> Subject: Announcing Interactive JScript
> >>
> >>
> >> Now available at
> >> http://www.EmpowermentZone.com/ijs.zip
> >>
> >> Interactive JScript
> >> Version 1.0
> >> February 7, 2008
> >> Copyright 2008 by Jamal Mazrui
> >> Modified GPL License
> >>
> >> I have wanted to build a JScript .NET interpreter.  I recently found an
> >> article with code by Andrew Norris that got me started:
> >>
> >> "A Simple JavaScript Command Line Interpreter for Windows in JScript.Net"
> >> http://listeningtoreason.blogspot.com/
> >> The original code has now been rewritten and extended considerably.
> >>
> >> Interactive JScript (IJS) is a console mode environment that can
> >> dynamically execute code in the JScript .NET language.  The source code
> >> is
> >> in a single file, ijs.js.  a batch file, build.bat, calls the JScript
> >> compiler, jsc.exe, which is distributed with the .NET Framework.  The
> >> resulting executable, ijs.exe, is about 40K in size.  It may be run from
> >> any directory on a computer that has the .NET Framework 2.0 (or above)
> >> installed.
> >>
> >> IJS may be used to run or test code in either standard JavaScript or the
> >> enhanced Microsoft JScript 8.0, which also serves as the script language
> >> for web development with ASP.NET.  The home page of the language is at
> >> http://msdn2.microsoft.com/en-us/library/72bd815a(VS.80).aspx
> >>
> >>   For example, a .js file can define a sophisticated snippet that may be
> >> invoked with the Alt+V command of the EdSharp editor, available at
> >> http://www.EmpowermentZone.com/edsetup.exe
> >>
> >> JScript code can also be evaluated by IronCOM, a COM server that provides
> >> traditional Win32 applications with access to functionality of the .NET
> >> Framework, available at
> >> http://www.EmpowermentZone.com/comsetup.exe
> >>
> >> The HomerKit library for JAWS
> >> http://www.EmpowermentZone.com/kitsetup.exe
> >>  includes a function called JSEval that wraps a JScript call via IronCOM,
> >> thereby enabling JAWS scripts to make .NET calls for functionality not
> >> available in the native scripting language.
> >>
> >> IJS may also be helpful for programming in .NET languages other than
> >> JScript.  Built in commands are defined for inquiring about available
> >> methods, properties, and events via reflection.  You can explore an
> >> object
> >> model, test expressions, save working code, and then convert it to the
> >> syntax of another .NET language.
> >>
> >> Reflecting on a COM object requires that a DLL be registered on the
> >> computer, described in the article
> >> "Inspect COM Components Using the TypeLib Information Object"
> >> http://msdn.microsoft.com/msdnmag/issues/1200/TypeLib/
> >>
> >> Registering this DLL (included in the archive) may be done at a command
> >> prompt as follows:
> >> RegSvr32 TlbInf32.dll
> >> Installing EdSharp does this automatically, and makes IJS conveniently
> >> available with the Go to Environment command, Control+Shift+G.
> >>
> >> IJS works well with a screen reader, since new output to the console is
> >> automatically read.  Periodically, the cls command is useful for clearing
> >> the screen and eliminating extra verbiage.  IJS may also be used as a
> >> simple, speech-friendly calculator, since most algebraic, trigonometric,
> >> and date calculations may be done with JScript.
> >>
> >> Below is the online documentation, available by entering the help command
> >> in Interactive JScript.  Questions, comments, or code contributions are
> >> welcome.
> >>
> >> Jamal
> >>
> >> Type a JScript statement, followed by Enter
> >> (a closing semicolon is not needed).
> >> Use UpArrow to repeat a command.
> >>  End a line of input with a space and underline ( _) to continue
> >> a multiline block of code.
> >> The prompt then changes from a > to _ character.
> >>
> >> Most classes of the .NET Framework 2.0 may be used in expressions.
> >> Variable types are inferred.
> >> To ease typing, the following namespaces are imported
> >> (there classes may be referenced without a namespace prefix):
> >> Microsoft.VisualBasic
> >> System
> >> System.Collections
> >> System.Data
> >> System.Diagnostics
> >> System.IO
> >> System.Reflection
> >> System.Text
> >> System.Windows.Forms
> >>
> >> In addition, the following built-in commands are available:
> >> quit = end this program
> >> cls = clear the screen
> >> eval FileName = execute a JScript file
> >> eval clipboard = execute JScript code on the clipboard
> >> cmd = pass any statement to the Windows command interpreter (cmd.exe)
> >> dos = execute a console-mode command and display its output
> >> log FileName = log output to a file
> >> log off = suspend logging
> >> log on = continue logging
> >> net Object = list members of a .NET object
> >> constructors Object = list its constructors only
> >> events Object = list its events only
> >> fields Object = list its fields only
> >> methods Object = list its methods only
> >> properties Object = list its properties only
> >> com Object = list members of a COM object
> >> dir Object = directory of members of either a .NET or COM object
> >>
> >> __________
> >> View the list's information and change your settings at
> >> //www.freelists.org/list/programmingblind
> >>
> >>
> >> __________
> >> View the list's information and change your settings at
> >> //www.freelists.org/list/programmingblind
> >>
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: