[jawsscripts] dot net, VBScript and JAWS scripting
- From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
- To: <jawsscripts@xxxxxxxxxxxxx>
- Date: Wed, 23 Jul 2008 09:19:34 +0100
Recently, while innocently Googling for something else entirely, I chanced
upon one of the Hey! Scripting Guy! articles, at:
http://technet.microsoft.com/en-us/magazine/cc162521(TechNet.10).aspx
which mentioned that it was possible to instantiate dot net classes directly
from VBScript. Presumably WindowEyes scripts written in VBScript could use
these techniques directly. By making the necessary small changes in syntax,
it is possible to use the same approach within JAWS scripts.
There are some limitations. Not all classes will play nicely. The class
has to be a simple public class. Any other modifier (abstract, static etc)
to the class seems to break the approach. I used the Object Viewer within
Visual Studio Express to look for suitable classes and see what methods were
available for each one. Not all methods are useable either, even when the
class can be instantiated. However, overloaded methods can be accessed,
using the approach shown for the Next () method in the System.Random example
in the above article.
So, assuming you have one of the dot net frameworks on your machine, you
can use the following components from the System.Collections
namespace directly, at least for manipulating strings : ArrayList,
CaseInsensitiveComparer, HashTable, Queue, Random and Stack
There are some other components in the Collections namespace which I
haven't tested, and potentially a large number of other possibilities. I've
seen that the Random class can handle integers passed as arguments, but I
haven't tested whether objects can be manipulated, and care sometimes has to
be taken with the type of any returned value.
Below is example JAWS code exercising some of the methods of the Stack
class.
Martin...
Script stackTest ()
Var object oStack, object oNull
Let oStack = CreateObject ("System.Collections.Stack")
oStack.Clear
oStack.Push ("plum")
oStack.Push ("blackberry")
oStack.Push ("orange")
oStack.Push ("banana")
SayString (oStack.Peek)
if (oStack.Contains ("banana") == -1) then
SayString ("banana present")
else
SayString ("we have no bananas")
endif
SayString ("the length of the stack is")
SayString (oStack.Count)
SayString (oStack.Pop)
SayString (oStack.Pop)
SayString ("the length of the stack is now")
SayString (oStack.Count)
if (oStack.Contains ("banana") == -1) then
SayString ("banana present")
else
SayString ("we have no bananas")
endif
Let oStack = oNull
EndScript
__________
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
Other related posts:
- » [jawsscripts] dot net, VBScript and JAWS scripting