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

  • From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 17 Jul 2015 12:35:15 -0800

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

Other related posts: