[jawsscripts] Re: Creating a Com Object in JAWS scripts

  • From: "Jim Snowbarger" <snowman@xxxxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Sun, 19 Jul 2015 18:02:18 -0500

But, the problem wasn't just that the test function wasn't available. It was
that the entire class wasn't visible.
So, the problem appears to be one level out.


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Peter Torpey
Sent: Saturday, July 18, 2015 12:05 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

I did not add any code to the IDL file manually. I assumed that any
function/method I added to the exposed class using the class wizard would
automatically expose any functions/methods I added to the exposed class. But
you are correct, there doesn't seem to be any mention of my test function in
the IDL file. I have no idea what code is required here and/or where it should
go in the IDL file.

In any case, I don't think I'm getting that far since JAWS is reporting that
the object for which I did define a dual interface is not even being created
when using the CreateObject function in JAWS.

The other strange thing which I don't understand is that when I add a function
/ method to my class using the class wizard, the function is added to the *.h
file and not to the corresponding *.cpp file. I would have expected such code
to end up in the *.cpp file.

I am not used to this Visual Studio paradigm and how it likes to do things.



-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel Haetir
Sent: Saturday, July 18, 2015 11:14 AM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

Did you add the test function declaration to the interface declaration in the
IDL file?

If it is only in the c++ class it is not going to be visible to COM.

On 7/18/15, Peter Torpey <ptorpey00@xxxxxxxxx> wrote:

Soronel,

Thanks for your very helpful suggestions on creating a COM object to
which I can connect with JAWS. As you say, creating the iDispatch
object within VS
2013 is a bit tricky with JAWS, but, following your direction, I did
get it to work.

So I created the ATL project with a class containing the necessary
iDispatch interfaces. Unfortunately, I still can't seem to connect a
JAWS script to an object inside my DLL. Something must be missing.

Here is what I did:

1. Created a SimpleDLL project that produces a DLL called
SimpleDLL.dll

2. Added a class called My Functs and set it up with a dual dispatch
interface as you described. I see this reference in my IDL file and
also see that the MyFuncts class contains a BeginCOM method under Maps.
I also added a function inside the MYFuncts class that just returns an
integer value for test purposes.

3. Registered the DLL by running:
regsvr32 SimpleDLL.dll
Using regedit , tis appears in the registry as:
SimpleDLLLib

4. Created the test JAWS script that looks like:
Script test()
Var object o = CreateObject( "MyFuncts", "SimpleDLL.dll" ) ; test to
see if the object was created:
if !o then
SayString("The object was not created") else
SayString("success: the object was created!"); EndIf

5. The object does not seem to have been created, nor can I then
access my test function within the object.

6. I also tried the CreateObjectEx JAWS function to create the
object, but again, no success.

Any suggestions? What am I missing here. The process seems like it
should be rather straightforward.

Thanks.

--Pete


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel Haetir
Sent: Friday, July 17, 2015 4:35 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

Oh, also for what we have been talking about CreateObject should be
needed, not CreateObjectEx. CreateObjectEx is needed if the object is
not registered but what we have discussed involves using regsvr32 so
that is not an issue.

On 7/17/15, Soronel Haetir <soronel.haetir@xxxxxxxxx> wrote:
You would still have to know a .net language, along with the required
attributes. Plus there are still lots of low-level OS things that are
simply way easier in native c++ than from .net (unlike jaws scripting
for the most part you can still accomplish these tasks in .net, it is
just harder to do so).

I admit that COM is fairly complicated to grasp as a whole but once
you have the understanding doing something like what we have been
discussing is not particularly difficult.

On 7/17/15, Jim Snowbarger <snowman@xxxxxxxxxxxxxxxx> wrote:
This is great stuff, because it is the major way to extend jaws
script functionality by making your favorite helper logic in com
land where you can get access to more things than in script land.
But, we sure do need it to be an easier task. A friend of mine
provided me a com object as a dot net assembly. He is blind, and
didn't have any trouble doing that. I'm totally ignorant of how
that was done. But, I wonder if that might be an easier path.

-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel
Haetir
Sent: Thursday, July 16, 2015 4:00 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

Also, I just tried it and I was able to use the visual studio class
view to select an interface definition found in an idl file and add
a member declaration. And that member was automatically created in
the implementation class in the c++ source.

The add member wizard was definitely a pain to use with jaws but it
can be done.

I created an atl project, used the new item wizard to add an ATL class.
I
used the wizard to select a dual interface class.

Next, I brought up class view (found on the view menu) then went
down to the interface that corresponded to the class I had just
added.

On the right click menu there is Add, I selected member. The dialog
script came back with a error but I hit the yes button to continue.
After filling in the dialog I hit the finish button.

At that point the member was both added to the interface in the IDL
file and the class definition in the .h file as well as having a
skeleton implementation in the c++ source file.

On 7/16/15, Soronel Haetir <soronel.haetir@xxxxxxxxx> wrote:
The functionality for creating the interface via wizard is there
but honestly it is a pain to use. It was a pain to use when I could
see and is worse now that I can not.

And really, now that you have VS Pro, if you use ATL creating the
interface by hand in the IDL file and then the implementation in
your
c++ source is not that difficult.

Note that all of the following was written without attempting to
compile so there may well be stuff missing (and not just the uuid
values), but it should be close enough to give a good start at least.

IDL:

[uuid(...), version(1.0)]
library MyTypeLib
{
[object, uuid(...), oleautomation]
interface IMyInterface : IDispatch
{
[id(1)] HRESULT MyFunc();
[id(2), propget]
HRESULT Member([out, retval] int *); [id(2), propput] HRESULT
Member([in] int); };

[uuid(...)]
coclass MyClass
{
[default] interface IMyInterface;
};
}
;
header:

#include <atlbase.h>
#include <atlcom.h>
#import "<path>mytypelib.tlb"

class MyClass
: public CComObjectRoot,
public CComCoClass<MyClass, &__uuidof(MyTypeLib::MyClass)>, public
IDispatchImpl<MyTypeLib::IMyInterface,
&__uuidof(MyTypeLib::IMyInterface), LIBID_MyTypeLib> {
BEGIN_COM_MAP(MyClass)
COM_INTERFACE_ENTRY(MyTypeLib::IMyInterface)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

HRESULT MyFunction();
HRESULT get_Member(int *);
HRESULT put_Member(int);
};
c++ source:

#include "stdafx.h"
#include "myclass.h"

HRESULT MyClass::MyFunction()
{
return S_OK;
}
HRESULT MyClass::get_Member(long * pVal) {
if(!pVal)
return E_POINTER;

*pVal = 1;
return S_OK;
}
HRESULT MyClass::put_Member(long val) { // Do something with val
return S_OK; }...

OBJECT_ENTRY_AUTO(__uuidof(MyTypeLib::MyClass), MyClass);



On 7/16/15, Peter Torpey <ptorpey00@xxxxxxxxx> wrote:
I started out using VS Express 2013 but recently upgraded to the
Professional version. Yes, the Express version does lack many
tools that the Pro version has.

I did find the ability to make an ATL project, but didn't see any
options for having a Wizard create the necessary dual interface
and/or automatically adding the iDispatch items. From the
examples I found on the web, it seems like there may be a wizard
or checkbox that will do this, but the tutorials must have been
referencing an earlier version of Visual Studio and I can't seem
to find the check boxes or wizards referenced in any of the tutorials.
I don't think just creating an ATL project enables this additional
functionality (although maybe it does), so I'm wondering how to
enable these interfaces in my ATL project without having to add
all of these mysterious classes and interfaces manually. Is there a way?

Thanks.

--Pete


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel
Haetir
Sent: Thursday, July 16, 2015 11:27 AM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

I'm not sure that ATL is included with the free versions of VS,
sorry I forgot about that. I have Pro and it is definitely
included there, Along with the project wizards.

If the free versions do not have ATL you can do the IDispatch
steps that ATL helps with using DispGetIDsOfNames /DispCallFunc.
Uou will have to load the type library yourself in that case.
(Loading the type library thenusing those functions is how ATL
deals with wiring the implemtation of a dual interface to a
request made through IDispatch).
And in case you haven't understood the term before, a dual
interface is one that dervives from IDispatch but can also be called
directly.

On 7/16/15, Peter Torpey <ptorpey00@xxxxxxxxx> wrote:
Thanks for the info on dispatch objects and connecting a DLL to JAWS.

These Microsoft "help" pages are so full of links to links and
connections to sub topics and jargon that it is difficult to
follow and get the high level overview. Anyway, I think I
understand basically what has to be done.

I was hoping not to have to code up all of the interface
requirements and that there would be a simple way or wizard to
generate an ATL project and make use of COM. I did find some
tutorials (not Microsoft sites!) that describe how to do this
with older versions of Visual Studio, but I have VS
2013 and I didn't see the same options / dialogs for creating
such a project. Maybe I need to hunt around more and experiment.

If you have any suggestions for making a test project using some
kind of ATL wizard in VS 2013 that might give me a jump start.

Thanks.

--Pete


-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel
Haetir
Sent: Tuesday, July 14, 2015 3:18 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

It has everything to do with how the type is implemented in code.
It can also have a slight amount to do with how the project
itself is built if you use an IDL file to generate a type library
(which I recommend that you do) you will need to link that type
library as a resource when you build the project).

You can read about using ATL to ease several of the steps
involved with this process at
https://msdn.microsoft.com/en-us/library/ekfyh289.aspx

On 7/14/15, Peter Torpey <ptorpey00@xxxxxxxxx> wrote:
I don't know what a dispatched object is. How can I tell? Is
that something to do with the coding in C++ or how the project
is compiled in Visual Studio?

--Pete




-----Original Message-----
From: jawsscripts-bounce@xxxxxxxxxxxxx
[mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Soronel
Haetir
Sent: Tuesday, July 14, 2015 2:15 PM
To: jawsscripts@xxxxxxxxxxxxx
Subject: [jawsscripts] Re: Creating a Com Object in JAWS scripts

Is the object dispatch based? (either dual or purely an
IDispatch implementation)..

Jaws is not capable of dealing with non-dispatch based objects.

On 7/14/15, Peter Torpey <ptorpey00@xxxxxxxxx> wrote:
I created a DLL using Visual Studio and would like to connect
objects in the DLL in my JAWS scripts.


I am not seeing the object in JAWS and wonder if anyone has any
pointers.
Here is what I did:



1. Compiled test.DLL and made sure the manifest was embedded
in
the
DLL (in the Visual Studio Properties dialog).

2. Registered the DLL in Windows using:
regsvr32 (full path to DLL)
The return said that the DLL was properly registerd.

3. In my JAWS scripts I have the lines:
var object o = CreateObjectEx( "ObjectName", false, "test.dll"
)



Besides the fact that I am unable to access any of the methods
of the DLL from within JAWS, I have a test like:



If !o then

SayString( "object was not created";

EndIf



That verifies that the object was not created.



What am I doing wrong here? Is there something I'm missing in
the call to CreateObjectEx or how one should set the properties
inside VS to get this to work?



Thanks.



--Pete





__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx



--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx



--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




--
Soronel Haetir
soronel.haetir@xxxxxxxxx
__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts


__________

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts




__________�

View the list's information and change your settings at
//www.freelists.org/list/jawsscripts

Other related posts: