Help with API calls to external program

K

kiln

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

I changed that line to

hwnd = FindWindowEx(0&, 0&, vbNullString, EDAPI_WINDOWCAPTION)

and the hwnd is set to 264446. That's got to be good but the command
still does nothing. For instance,

EDAPISendCommandDan 3

does not close the Express Dictate window. (I renamed the function to
EDAPISendCommand so it wouldn't conflict with another effort).
 
D

dan artuso

Hi,
It's a very good sign that you're now getting a window handle.
Can you post the code for your EDAPISendCommandDan routine?
Also, let me know if Stephen has solved it for you!

PS I'm out of town for a few days so it might take a while for me to reply
again.

Dan Artuso, MVP
 
K

kiln

Hi Dan

I think the code I used was just copied from your suggestion:

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 Integer,
ByVal lParam As Any) As Long

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

Public Function EDAPISendCommandDan(iCommand As Integer) As Long
Dim hwnd As Long

hwnd = FindWindowEx(0&, 0&, vbNullString, EDAPI_WINDOWCAPTION)
'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
EDAPISendCommandDan = SendMessage(hwnd, WM_EDAPI_COMMAND,
iCommand, vbNullString)
End If
End Function

I was calling it like:

EDAPISendCommandDan 3

I'll let you know if another solution shows up. Thanks for your help!
 
D

dan artuso

Hi,
One last sugestion, try this for SendMessage:

EDAPISendCommandDan = SendMessage(hwnd, WM_EDAPI_COMMAND, iCommand, 0&)

instead of passing a Null string

Dan
 
S

Stephen Lebans

I simply changed your call to FIndWIndowEx to use vbNullString fo rthe
WIndow Class param and the Get Ed Ver , New DIctation and Exit Ed
functions all worked properly.

To get the Rename function to work you just have to change the existing
call to the SendMessage API to pass the lExtraData param ByVal instead
of the current ByRef.

Everything seems to be working now.
--

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

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