Help with API calls to external program

K

kiln

I'm not familiar with API calls to external programs. A program I might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most important
for my purposes.
 
D

Dan Artuso

Hi,
If I'm understanding the doc correctly, you need to use two Windows API functions
to communicate with Express Dictate. So you must declare these functions:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp, WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and then you send it messages indicating what 'command'

you want it run.

Anyway, That's the best I can do and I have no way to test it so your on your own!!
 
D

Dan Artuso

Oops, sorry, one correction.
EDAPISendCommand = SendMessage(hwnd, WM_EDAPI_COMMAND, iCommand, vbNullString)


--
HTH
Dan Artuso, Access MVP


Dan Artuso said:
Hi,
If I'm understanding the doc correctly, you need to use two Windows API functions
to communicate with Express Dictate. So you must declare these functions:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp, WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and then you send it messages indicating what 'command'

you want it run.

Anyway, That's the best I can do and I have no way to test it so your on your own!!




--
HTH
Dan Artuso, Access MVP


kiln said:
I'm not familiar with API calls to external programs. A program I might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most important
for my purposes.
 
D

Dirk Goldgar

kiln said:
I'm not familiar with API calls to external programs. A program I
might need to interact with, Express Dictate, has a tiny SDK located
at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does
that make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program
Files\NCH Swift Sound\Express\express.exe" Alias
"EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most
important for my purposes.

This is not my strong suit, but I think it will be something along these
lines:

'----- start of module code -----
Option Compare Database
Option Explicit

Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) _
As Long

Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) _
As Long

Private Declare Function GlobalAddAtom Lib "kernel32" _
Alias "GlobalAddAtomA" _
(ByVal lpString As String) As Long

Private Declare Function GlobalDeleteAtom Lib "kernel32" _
(ByVal nAtom As Long) As Long


Private Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Private Const WM_EDAPI_COMMAND As Long = &H7FFF

Function EDAPISendCommandString(lCommand As Long, szStringToSend As
String) _
As Long

Dim lAtomExtraInfo As Long

lAtomExtraInfo = GlobalAddAtom(szStringToSend)
EDAPISendCommandString = EDAPISendCommand(lCommand, lAtomExtraInfo)
Call GlobalDeleteAtom(lAtomExtraInfo)

End Function

Function EDAPIGetVersion() As Long
EDAPIGetVersion = EDAPISendCommandSimple(0&)
' Returns the current API version which is currently 1.
' If 0 is returned the API is not available.
' If 2 or above is returned please contact us for updated
documentation.
End Function

Function EDAPIOpen()
' Opens the Express Dictate window and brings it to the front.
EDAPISendCommandSimple 1&
End Function

Function EDAPIHide()
' Hides Express Dictate (minimizes it to the task bar).
EDAPISendCommandSimple 2&
End Function

Function EDAPIExit()
' Exits Express Dictate (quits - no further commands will be
accepted).
EDAPISendCommandSimple 3&
End Function

Function EDAPINew()
' Creates a new dictation and selects that file
EDAPISendCommandSimple 4&
End Function

Function EDAPIRename(szNewDictationName As String)
' Renames the current dictation
EDAPISendCommandString 5&, szNewDictationName
End Function

Function EDAPISetData(szData As String)
' Adds data to the dictation notes.
' Usually this should be in tagged xml form.
' eg. EDAPISetData("<caseno>123456</caseno>");
' As many data fields can be set as required.
' This data can be extracted from the sent dct files
' using etools www.nch.com.au/etools if required.
EDAPISendCommandString 6&, szData
End Function

Function EDAPIGetUserID() As Long
' Returns the registration ID of the current user.
' The registration ID of each user will always be unique.
' Together with the file number, the user ID and
' file number can be used to uniquely identify any file
' in the system.
' The UserID is also included in the dct header. See
' www.nch.com.au/etools for more.
EDAPIGetUserID = EDAPISendCommandSimple(7&)
End Function

Function EDAPIGetFileNo() As Long
' Returns the unique file ID of the current file.
' The FileNumber is also included in the dct header. See
' www.nch.com.au/etools for more.
EDAPIGetFileNo = EDAPISendCommandSimple(8&)
End Function

Function EDAPISend()
' Sends the current dictation to the default recipient
EDAPISendCommandSimple 9&
End Function

Function EDAPIDelete()
' Deletes the current dictation
EDAPISendCommandSimple 10&
End Function

Function EDAPISendCommandSimple(lCommand As Long) As Long

EDAPISendCommandSimple = EDAPISendCommand(lCommand, 0&)

End Function

Function EDAPISendCommand(lCommand As Long, lExtraData As Long) _
As Long

Dim hwndIVM As Long
Dim lProcess As Long

hwndIVM = FindWindowEx(0&, 0&, 0&, EDAPI_WINDOWCAPTION)

If (hwndIVM = 0) Then
' Express Dictate is not running.
' Attempt to run it.
lProcess = Shell("C:\Program Files\NCH Swift
Sound\Express\express.exe")
If lProcess = 0 Then
MsgBox "Unable to start Express Dictate!"
Exit Function
Else
hwndIVM = FindWindowEx(0&, 0&, 0&, EDAPI_WINDOWCAPTION)
End If
End If

If (hwndIVM = 0) Then
' Express Dictate is *still* not running!
EDAPISendCommand = 0
Else
EDAPISendCommand = _
SendMessage(hwndIVM, WM_EDAPI_COMMAND, lCommand, lExtraData)
End If

End Function
'----- end of module code -----

I doubt very much that this is all correct, but I hope it's getting
close.
 
K

kiln

Woah - thanks! What a contribution, even if it might not be without
error! I'll give it a shot tonight... many thanks!

kiln said:
I'm not familiar with API calls to external programs. A program I
might need to interact with, Express Dictate, has a tiny SDK located
at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does
that make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program
Files\NCH Swift Sound\Express\express.exe" Alias
"EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most
important for my purposes.

This is not my strong suit, but I think it will be something along these
lines:

'----- start of module code -----
Option Compare Database
Option Explicit

Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) _
As Long

Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
 
S

Stephen Lebans

Dan your Declaration for the SendMessageA API should use a LONG instead
of INTEGER.
:)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Dan Artuso said:
Hi,
If I'm understanding the doc correctly, you need to use two Windows API functions
to communicate with Express Dictate. So you must declare these functions:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp,
WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and
then you send it messages indicating what 'command'
you want it run.

Anyway, That's the best I can do and I have no way to test it so your on your own!!




--
HTH
Dan Artuso, Access MVP


I'm not familiar with API calls to external programs. A program I might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most important
for my purposes.
 
D

Dan Artuso

You're right (as usual!). :)
I copied from the API guide which oddly enough uses a Long in the sample declaration
but then uses Integer for the code sample.

--

Dan Artuso, Access MVP


Stephen Lebans said:
Dan your Declaration for the SendMessageA API should use a LONG instead
of INTEGER.
:)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Dan Artuso said:
Hi,
If I'm understanding the doc correctly, you need to use two Windows API functions
to communicate with Express Dictate. So you must declare these functions:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp,
WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and
then you send it messages indicating what 'command'
you want it run.

Anyway, That's the best I can do and I have no way to test it so your on your own!!




--
HTH
Dan Artuso, Access MVP


I'm not familiar with API calls to external programs. A program I might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most important
for my purposes.
 
P

PC Datasheet

Dan,

What is the API Guide you reference here?

Steve


Dan Artuso said:
You're right (as usual!). :)
I copied from the API guide which oddly enough uses a Long in the sample declaration
but then uses Integer for the code sample.

--

Dan Artuso, Access MVP


Dan your Declaration for the SendMessageA API should use a LONG instead
of INTEGER.
:)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Dan Artuso said:
Hi,
If I'm understanding the doc correctly, you need to use two Windows API functions
to communicate with Express Dictate. So you must declare these functions:

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp,
WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and
then you send it messages indicating what 'command'
you want it run.

Anyway, That's the best I can do and I have no way to test it so your on your own!!




--
HTH
Dan Artuso, Access MVP


I'm not familiar with API calls to external programs. A program I might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most important
for my purposes.
 
K

kiln

All of your code compiled fine, but unfortunately the only function that
seems to do anything to Express Dictate or the Diction in it is the
function that opens ED. I'll see if I can figure out why but I thought
I'd let you know in case something occurs to you.

kiln said:
I'm not familiar with API calls to external programs. A program I
might need to interact with, Express Dictate, has a tiny SDK located
at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call to
this API.

[1] Most literature refers to calling dlls - this is an exe - does
that make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program
Files\NCH Swift Sound\Express\express.exe" Alias
"EDAPISendCommandSimple(0)" ()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most
important for my purposes.

This is not my strong suit, but I think it will be something along these
lines:

'----- start of module code -----
Option Compare Database
Option Explicit

Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) _
As Long

Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
 
K

kiln

All calls to EDAPISendCommand() fail on the following line:

hwnd = FindWindowEx(Null, Null, Null, EDAPI_WINDOWCAPTION)

invalid use of null, it's because hwnd is long.

EDAPISendCommand 3 for instance should close an open instance of ED but
dones not.

Also, was Stephan's ref to Integer to

ByVal wParam As Integer ?

That was the only integer ref I could find in your code but the way it
was described made is sound like I should expect some other use.
 
D

Dirk Goldgar

kiln said:
All of your code compiled fine, but unfortunately the only function
that seems to do anything to Express Dictate or the Diction in it is
the function that opens ED. I'll see if I can figure out why but I
thought I'd let you know in case something occurs to you.

The only thing that I know might be a problem is a timing issue: we are
warned that we must allow time between shelling to ExpressDictate and
running FindWinowEx to locate its window. What happens if you start
ExpressDictate independently, from Explorer or the Start menu, and then
try calling one of the simple functions like EDAPIGetVersion() ?
 
K

kiln

The only thing that I know might be a problem is a timing issue: we are
warned that we must allow time between shelling to ExpressDictate and
running FindWinowEx to locate its window. What happens if you start
ExpressDictate independently, from Explorer or the Start menu, and then
try calling one of the simple functions like EDAPIGetVersion() ?
Hi Dirk

Yes, I tried that right away and it doesn't seem to make any difference.
For instance, the ver call, and the exit call. All most do is to bring
ED to the forefront.

Thanks
 
D

Dirk Goldgar

kiln said:
Hi Dirk

Yes, I tried that right away and it doesn't seem to make any
difference. For instance, the ver call, and the exit call. All most
do is to bring
ED to the forefront.

Hmm, if they're doing *something* we're at least getting somewhere.
Unfortunately, I can't test any of this here. The best I can suggest is
to step through the code and see what happens along the way. You might
post your calling code in case you've made an obvious mistake, but from
prior threads we've had I don't think that's all that likely. No, it's
most likely my error -- I warned you that this wasn't my strong suit.
Maybe Stephen Lebans will take a look at my translations of the C++
functions and tell us where I went wrong.
 
K

kiln

Yes, the calling code should be ok, it's bare bones for testing, like:

Private Sub cmdExit_Click()
EDAPIExit
End Sub

I'll see what debugging reveals but all of this is pretty mysterious to
me. Thanks for you help!
 
K

kiln

Interesting; this code seems to fail for the same reason that the code
snippet provided by Dan does.

In EDAPISendCommand() are these couple of lines

hwndIVM = FindWindowEx(0&, 0&, 0&, EDAPI_WINDOWCAPTION)

If (hwndIVM = 0) Then
' Express Dictate is not running.

hwndIVM never strays from being equal to zero, even after the attempt is
made in this very function to start Express Dictate. That what failed
with the code Dan provided. Something about the caption value isn't
right, altho the visible caption *is* "Express Dictate" as both of you
provided for. Note, ED was already running when I called the Exit
routine.

If this keeps up I might get a clue about API calls, that would be cool!

Thanks
 
S

Stephen Lebans

If you send me a ZIP file containing your sample MDB and all of the
external Exress Dictate files requried I'll have a look at it for you. I
don't want to spend the time learning how to use it so please include
everything I will need along with some instructions.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Dan Artuso

Hi Steve,
http://www.mentalis.org/agnet/apiguide.shtml

--
HTH
Dan Artuso, Access MVP


PC Datasheet said:
Dan,

What is the API Guide you reference here?

Steve


Dan Artuso said:
You're right (as usual!). :)
I copied from the API guide which oddly enough uses a Long in the sample declaration
but then uses Integer for the code sample.

--

Dan Artuso, Access MVP


Dan your Declaration for the SendMessageA API should use a LONG instead
of INTEGER.
:)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Hi,
If I'm understanding the doc correctly, you need to use two Windows
API functions
to communicate with Express Dictate. So you must declare these
functions:

Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" _

(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String,
ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
_

(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer,
ByVal lParam As Any) As Long

'and these

Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Const WM_EDAPI_COMMAND As Long = &H7FFF

Now for your user defined function:



Public Function EDAPISendCommand( iCommand As Integer) As Long
Dim hwnd As Long
hwnd = FindWindowEx(NULL, NULL, NULL, EDAPI_WINDOWCAPTION);
If hwnd = 0 Then ' Express Dictate not running.
'Either attempt to run Express Dictate
' or spit out error message here...
Exit Function

Else
EDAPISendCommand = SendMessage(Application.hWndAccessApp,
WM_EDAPI_COMMAND, iCommand, vbNullString);
End If
End Function

The idea is that you get a Handle to the Express Dictate window and
then you send it messages indicating what 'command'

you want it run.

Anyway, That's the best I can do and I have no way to test it so your
on your own!!




--
HTH
Dan Artuso, Access MVP


I'm not familiar with API calls to external programs. A program I
might
need to interact with, Express Dictate, has a tiny SDK located at

http://www.nch.com.au/express/sdk.html

So far I've not been able to blunder my way into a successful call
to
this API.

[1] Most literature refers to calling dlls - this is an exe - does
that
make any difference?

[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.

[3] Mininally I need to test for ver, open Express Dictate, and
rename
the dictation. Those would be 0,1,5.

[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program
Files\NCH
Swift Sound\Express\express.exe" Alias "EDAPISendCommandSimple(0)"
()

Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function

Running EDVer gets me a "can't find DLL entry point..." error
message.

I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most
important
for my purposes.
 
D

Dan Artuso

Hi,
Just out of curiosity, what happens if you change it to this:
hwndIVM = FindWindowEx(0&, 0&, vbNullString, EDAPI_WINDOWCAPTION)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top