473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

tapiRequestMakeCall - How to customize behavior?

The below code dials a phone number when the subform datasheet cell
containing the number is double clicked. The problem is that the dialer
application (c:\windows\dialer.exe) pops up windows on the screen, requiring
user intervention to click "Talk" or "Hang Up". I want to customize the
behavior of the application so that no pop ups are received and the
application drops the line automatically and closes itself in 6 seconds -
which is enough time for the user to pick up the phone. The user will hear
the modem dial, but no other screen alerts will be received. If the phone
is not picked up with the 6-second window, the call is simply dropped.

Perhaps I need to write my own custom version of TAPI32.DLL? Or is there a
way to customize the behavior of this code to suit my needs? I've created
my own DLLs in the past, though am still somewhat of a novice.

[Form_frm0Telephone]
Option Compare Database
Option Explicit
Private Declare Function tapiRequestMakeCall Lib "TAPI32.DLL" _
(ByVal DestAddress As String, ByVal AppName As String, _
ByVal CalledParty As String, ByVal Comment As String) As Long

Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
Dim lngRetVal As Long
Dim strDial As String
strDial = Forms!frm0!frm0Telephone.Form!TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
End Sub

Thanks in advance.

PS. thanks to Bruce Thompson and Joacim Andersson for help getting this far.
Nov 12 '05 #1
17 11576
> The below code dials a phone number when the subform datasheet cell
containing the number is double clicked. The problem is that the dialer
application (c:\windows\dialer.exe) pops up windows on the screen, requiring user intervention to click "Talk" or "Hang Up". I want to customize the
behavior of the application so that no pop ups are received and the
application drops the line automatically and closes itself in 6 seconds -
which is enough time for the user to pick up the phone. The user will hear the modem dial, but no other screen alerts will be received. If the phone
is not picked up with the 6-second window, the call is simply dropped.


This is close - but how to minimize and close an application (dialer.exe) in
VBA?

[Form_frm0Telephone]
Option Compare Database
Option Explicit
Private Declare Function tapiRequestMakeCall Lib "TAPI32.DLL" _
(ByVal DestAddress As String, ByVal AppName As String, _
ByVal CalledParty As String, ByVal Comment As String) As Long

Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
Dim WaitTime As Variant
Dim Start As Variant
Dim strDial As String
Dim lngRetVal As Long
strDial = Forms!frm0!frm0Telephone.Form!TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
'Shell("c:\windows\dialer.exe", 0) '<<=== How to minimize app?
If lngRetVal <> 0 Then GoTo Exit_Here
WaitTime = 6
Start = Timer
Do While Timer < Start + WaitTime
DoEvents
Loop
Exit_Here:
'Close "c:\windows\dialer.exe" '<<=== How to close app?
End Sub
Nov 12 '05 #2
From my file - I haven't tried it!

If you get it to work, please email me a copy of your code.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Dial Telephone Numbers From A Form

Note: Windows Dialer must be loaded on the machine for this code to work....

In the Form Module

Private Sub Phone1_DblClick(Cancel As Integer)
Call CtrDialer_Click
End Sub
In a New Module

Public Sub CtrDialer_Click()
On Error GoTo Err_CtrDialer_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91

Set PrevCtl = Screen.ActiveControl

If TypeOf PrevCtl Is TextBox Then
stDialStr = IIf(varType(PrevCtl) > V_NULL, PrevCtl, "")
ElseIf TypeOf PrevCtl Is ListBox Then
stDialStr = IIf(varType(PrevCtl) > V_NULL, PrevCtl, "")
ElseIf TypeOf PrevCtl Is ComboBox Then
stDialStr = IIf(varType(PrevCtl) > V_NULL, PrevCtl, "")
Else
stDialStr = ""
End If

Application.Run "utility.wlib_AutoDial", stDialStr
Exit_CtrDialer_Click:
Exit Sub

Err_CtrDialer_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_CtrDialer_Click

End Sub
"deko" <de**@hotmail.com> wrote in message
news:48*******************@newssvr29.news.prodigy. com...
The below code dials a phone number when the subform datasheet cell
containing the number is double clicked. The problem is that the dialer
application (c:\windows\dialer.exe) pops up windows on the screen, requiring
user intervention to click "Talk" or "Hang Up". I want to customize the
behavior of the application so that no pop ups are received and the
application drops the line automatically and closes itself in 6 seconds -
which is enough time for the user to pick up the phone. The user will hear
the modem dial, but no other screen alerts will be received. If the phone
is not picked up with the 6-second window, the call is simply dropped.

Perhaps I need to write my own custom version of TAPI32.DLL? Or is there a
way to customize the behavior of this code to suit my needs? I've created
my own DLLs in the past, though am still somewhat of a novice.

[Form_frm0Telephone]
Option Compare Database
Option Explicit
Private Declare Function tapiRequestMakeCall Lib "TAPI32.DLL" _
(ByVal DestAddress As String, ByVal AppName As String, _
ByVal CalledParty As String, ByVal Comment As String) As Long

Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
Dim lngRetVal As Long
Dim strDial As String
strDial = Forms!frm0!frm0Telephone.Form!TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
End Sub

Thanks in advance.

PS. thanks to Bruce Thompson and Joacim Andersson for help getting this far.

Nov 12 '05 #3
> If you get it to work, please email me a copy of your code.

This code is effective for closing the pop up windows, but it won't close
the app - Dialer.exe. Apparently the AppCaption is not what appears in the
window header of the application window - i.e. "Phone Dialer". Is there a
way to find the caption programmatically? Perhaps there is an easier way to
simply close an application in VB. There must be. When I find that
solution, I'll probably modify the below code to hide (rather than close)
the pop up windows and then close (cleanly) Dialer.exe (and by association
the popups) after the 6-second WaitTime.

Option Compare Database
Option Explicit
'API Find applcation by full caption
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long

'API Bring Window to foreground
Private Declare Function SetForegroundWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long

'API Send message to application
Private Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) _
As Long

Const WM_CLOSE = &H10

Function Close_By_Caption(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
'Bring to Front
SetForegroundWindow hwnd
'Close the app nicely
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
End Function

Private Sub cmdTest_Click()
'Close_By_Caption ("Dialing") - works great
'Close_By_Caption ("Call Status") - works great
Colse_By_Caption ("Phone Dialer") - does not work
End Sub
Nov 12 '05 #4
deko wrote:
If you get it to work, please email me a copy of your code.

This code is effective for closing the pop up windows, but it won't close
the app - Dialer.exe. Apparently the AppCaption is not what appears in the
window header of the application window - i.e. "Phone Dialer". Is there a
way to find the caption programmatically? Perhaps there is an easier way to
simply close an application in VB. There must be. When I find that
solution, I'll probably modify the below code to hide (rather than close)
the pop up windows and then close (cleanly) Dialer.exe (and by association
the popups) after the 6-second WaitTime.

< SNIP >

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why not use the code found here instead of the Dialer.exe method.

ACC: How to Dial a Phone Number from MS Access 95/97

http://support.microsoft.com/default...b;en-us;148857

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQHwkL4echKqOuFEgEQLDAQCgnX02cV7FYpM8h70V8FAhEy OV4ggAoNfp
p9lGoUPu5F5haOAot3Lh6RaE
=Yb1F
-----END PGP SIGNATURE-----

Nov 12 '05 #5
> Why not use the code found here instead of the Dialer.exe method.

ACC: How to Dial a Phone Number from MS Access 95/97

http://support.microsoft.com/default...b;en-us;148857


I looked at that code - not sure if it will make use of Dialing Properties,
and I think using the TAPI interface is a better solution.

The below code works - my only complaint is that I can't hide the "Call
Status" window. I'm sure my syntax is wrong somewhere... not sure where.
Keep getting Error Number 49: Bad DLL calling convention...

Option Compare Database
Option Explicit
Const WM_CLOSE = &H10
'Const SW_HIDE = 0

'API use Phone Dialer to make call (default dialer)
Private Declare Function tapiRequestMakeCall _
Lib "TAPI32.DLL" _
( _
ByVal DestAddress As String, _
ByVal AppName As String, _
ByVal CalledParty As String, _
ByVal Comment As String _
) _
As Long

'API find applcation by full caption
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long

'API bring Window to foreground
Private Declare Function SetForegroundWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long

'API set ShowWindow to hide window
Private Declare Function ShowWindow _
Lib "user32" _
( _
ByVal hwnd As Long, _
ByVal nCmdShow As Integer _
)

'API send message to application
Private Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) _
As Long

Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
Debug.Print hwnd
Debug.Print AppCaption
ShowWindow hwnd, 0
End If
End Function

'not using this function
Private Function Close_By_Caption(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
'Bring to Front
SetForegroundWindow hwnd
'Close the app nicely
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
Exit_Here:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frm0Telephone"), ("Close_By_Caption")
End Select
Resume Exit_Here
End Function

Private Function CloseAPP(AppNameOfExe As String, _
Optional KillAll As Boolean = False, _
Optional NeedYesNo As Boolean = True) _
As Boolean
Dim oProcList As Object
Dim oWMI As Object
Dim oProc As Object
CloseAPP = False
'create WMI object instance:
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
'create object collection of Win32 processes:
Set oProcList = oWMI.InstancesOf("win32_process")
'iterate through the enumerated collection:
For Each oProc In oProcList
'Debug.Print oProc.Name
'option to close a process:
If UCase(oProc.Name) = UCase(AppNameOfExe) Then
NeedYesNo = False 'don't wan't msgbox
If NeedYesNo Then
If MsgBox("Kill " & oProc.Name & vbNewLine & "Are you
sure?", _
vbYesNo + vbCritical) = vbYes Then
oProc.Terminate (0)
CloseAPP = True
End If
Else
oProc.Terminate (0)
CloseAPP = True
End If
'continue search for more?
If Not KillAll And CloseAPP Then
Exit For 'oProc In oProcList
End If
End If
Next
Else
'report error
End If
Exit_Here:
Set oProcList = Nothing
Set oWMI = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frm0Telephone"), ("Close_APP")
End Select
Resume Exit_Here
End Function

Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
On Error GoTo HandleErr
Dim varDialWait As Variant
Dim varStart As Variant
Dim strDial As String
Dim lngRetVal As Long
Static blnDialing As Boolean 'prevent reentry into sub while dialing
DoEvents
blnDialing = False
If blnDialing Then Exit Sub
blnDialing = True
strDial = Forms!frm0!frm0Telephone.Form!TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
If lngRetVal <> 0 Then Exit Sub
varDialWait = DLookup("DialWait", "tblPrefs")
varStart = Timer
Do While Timer < varStart + varDialWait
DoEvents
'Hide_Window ("Call Status") '<<=== this fails with Error Number 49:
Bad DLL calling convention
Loop
Exit_Here:
On Error Resume Next
blnDialing = False
CloseAPP ("dialer.exe")
Exit Sub
HandleErr:
Select Case Err.Number
Case 94 'Invalid Use of Null - if double click on blank, open dialer
Call Shell("c:\windows\dialer.exe", vbNormalFocus)
blnDialing = False
Exit Sub
Case Else
modHandler.LogErr ("frm0Telephone"),
("Telephone_Numbers_DblClick")
End Select
Resume Exit_Here
End Sub
Nov 12 '05 #6
You can use SPY++ if you have VC++( or I think even VB) on your system
to determine the Class name of the offending Dialog. Modify your code to
find the window by Class name instead of Caption.

If you do not have SPY++ send me a functioning MDB and I'll post the
Class name for the Dialog.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:Wj*******************@newssvr25.news.prodigy. com...
Why not use the code found here instead of the Dialer.exe method.

ACC: How to Dial a Phone Number from MS Access 95/97

http://support.microsoft.com/default...b;en-us;148857
I looked at that code - not sure if it will make use of Dialing

Properties, and I think using the TAPI interface is a better solution.

The below code works - my only complaint is that I can't hide the "Call Status" window. I'm sure my syntax is wrong somewhere... not sure where. Keep getting Error Number 49: Bad DLL calling convention...

Option Compare Database
Option Explicit
Const WM_CLOSE = &H10
'Const SW_HIDE = 0

'API use Phone Dialer to make call (default dialer)
Private Declare Function tapiRequestMakeCall _
Lib "TAPI32.DLL" _
( _
ByVal DestAddress As String, _
ByVal AppName As String, _
ByVal CalledParty As String, _
ByVal Comment As String _
) _
As Long

'API find applcation by full caption
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long

'API bring Window to foreground
Private Declare Function SetForegroundWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long

'API set ShowWindow to hide window
Private Declare Function ShowWindow _
Lib "user32" _
( _
ByVal hwnd As Long, _
ByVal nCmdShow As Integer _
)

'API send message to application
Private Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) _
As Long

Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
Debug.Print hwnd
Debug.Print AppCaption
ShowWindow hwnd, 0
End If
End Function

'not using this function
Private Function Close_By_Caption(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
'Bring to Front
SetForegroundWindow hwnd
'Close the app nicely
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
Exit_Here:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frm0Telephone"), ("Close_By_Caption")
End Select
Resume Exit_Here
End Function

Private Function CloseAPP(AppNameOfExe As String, _
Optional KillAll As Boolean = False, _
Optional NeedYesNo As Boolean = True) _
As Boolean
Dim oProcList As Object
Dim oWMI As Object
Dim oProc As Object
CloseAPP = False
'create WMI object instance:
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
'create object collection of Win32 processes:
Set oProcList = oWMI.InstancesOf("win32_process")
'iterate through the enumerated collection:
For Each oProc In oProcList
'Debug.Print oProc.Name
'option to close a process:
If UCase(oProc.Name) = UCase(AppNameOfExe) Then
NeedYesNo = False 'don't wan't msgbox
If NeedYesNo Then
If MsgBox("Kill " & oProc.Name & vbNewLine & "Are you sure?", _
vbYesNo + vbCritical) = vbYes Then
oProc.Terminate (0)
CloseAPP = True
End If
Else
oProc.Terminate (0)
CloseAPP = True
End If
'continue search for more?
If Not KillAll And CloseAPP Then
Exit For 'oProc In oProcList
End If
End If
Next
Else
'report error
End If
Exit_Here:
Set oProcList = Nothing
Set oWMI = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frm0Telephone"), ("Close_APP")
End Select
Resume Exit_Here
End Function

Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
On Error GoTo HandleErr
Dim varDialWait As Variant
Dim varStart As Variant
Dim strDial As String
Dim lngRetVal As Long
Static blnDialing As Boolean 'prevent reentry into sub while dialing DoEvents
blnDialing = False
If blnDialing Then Exit Sub
blnDialing = True
strDial = Forms!frm0!frm0Telephone.Form!TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
If lngRetVal <> 0 Then Exit Sub
varDialWait = DLookup("DialWait", "tblPrefs")
varStart = Timer
Do While Timer < varStart + varDialWait
DoEvents
'Hide_Window ("Call Status") '<<=== this fails with Error Number 49: Bad DLL calling convention
Loop
Exit_Here:
On Error Resume Next
blnDialing = False
CloseAPP ("dialer.exe")
Exit Sub
HandleErr:
Select Case Err.Number
Case 94 'Invalid Use of Null - if double click on blank, open dialer Call Shell("c:\windows\dialer.exe", vbNormalFocus)
blnDialing = False
Exit Sub
Case Else
modHandler.LogErr ("frm0Telephone"),
("Telephone_Numbers_DblClick")
End Select
Resume Exit_Here
End Sub


Nov 12 '05 #7
> If you do not have SPY++ send me a functioning MDB and I'll post the
Class name for the Dialog.


Hi Stephen,

It's on it's way...

Thanks!
Nov 12 '05 #8
On Apr 13 2004, 05:05 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WW****************@linvalid.com> wrote in news:lCYec.17978$Np3.635507@ursa-
nb00s0.nbnet.nb.ca:
You can use SPY++ if you have VC++( or I think even VB) on your system
to determine the Class name of the offending Dialog. Modify your code to
find the window by Class name instead of Caption.


Or, if you don't have Spy++, you can use Wintree from
http://www.users.cloud9.net/~dfurman/code.htm

--
remove a 9 to reply by email
Nov 12 '05 #9
A couple of errors in your API declarations seem to be the problem. The
second ShowWindow param should be a Long not Integer.
Notice I changed the last SendMessage param to ByValue instead of ByRef.
You were passing a 0 which is interpreted as the memory location at
address ZERO.
Also remember that hWnds can be negative in WinNT or higher so the
standard check is against 0.

I have tested the code below and it works.
Option Compare Database
Option Explicit
Const WM_CLOSE = &H10
'Const SW_HIDE = 0

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
'API use Phone Dialer to make call
Private Declare Function tapiRequestMakeCall _
Lib "TAPI32.DLL" _
( _
ByVal DestAddress As String, _
ByVal AppName As String, _
ByVal CalledParty As String, _
ByVal Comment As String _
) _
As Long

'API find applcation by full caption
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long

'API bring Window to foreground
Private Declare Function SetForegroundWindow _
Lib "user32" _
( _
ByVal hwnd As Long _
) _
As Long

'API set ShowWindow to hide window
Private Declare Function ShowWindow _
Lib "user32" _
( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long _
)

'API send message to application
Private Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long _
) _
As Long
Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
Debug.Print hwnd
Debug.Print AppCaption
ShowWindow hwnd, 0
End If
End Function
Private Function Close_By_Caption(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd <> 0 Then
'Bring to Front
SetForegroundWindow hwnd
'Close the app nicely
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
Exit_Here:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
'modHandler.LogErr ("frm0Telephone"), ("Close_By_Caption")
End Select
Resume Exit_Here
End Function
Private Function CloseAPP(AppNameOfExe As String, _
Optional KillAll As Boolean = False, _
Optional NeedYesNo As Boolean = True) _
As Boolean
Dim oProcList As Object
Dim oWMI As Object
Dim oProc As Object
CloseAPP = False
'create WMI object instance:
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
'create object collection of Win32 processes:
Set oProcList = oWMI.InstancesOf("win32_process")
'iterate through the enumerated collection:
For Each oProc In oProcList
'Debug.Print oProc.Name
'option to close a process:
If UCase(oProc.Name) = UCase(AppNameOfExe) Then
NeedYesNo = False 'don't wan't msgbox
If NeedYesNo Then
If MsgBox("Kill " & oProc.Name & vbNewLine & "Are
you sure?", _
vbYesNo + vbCritical) = vbYes Then
oProc.Terminate (0)
CloseAPP = True
End If
Else
oProc.Terminate (0)
CloseAPP = True
End If
'continue search for more?
If Not KillAll And CloseAPP Then
Exit For 'oProc In oProcList
End If
End If
Next
Else
'report error
End If
Exit_Here:
Set oProcList = Nothing
Set oWMI = Nothing
Exit Function
HandleErr:
Select Case Err.Number
Case Else
'modHandler.LogErr ("frm0Telephone"), ("Close_APP")
End Select
Resume Exit_Here
End Function
Private Sub Telephone_Numbers_DblClick(Cancel As Integer)
On Error GoTo HandleErr
Dim varDialWait As Variant
Dim varStart As Variant
Dim strDial As String
Dim lngRetVal As Long
Static blnDialing As Boolean 'prevent reentry into sub while dialing
DoEvents
blnDialing = False
If blnDialing Then Exit Sub
strDial = Me.TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
If lngRetVal = 0 Then
blnDialing = True
'varDialWait = DLookup("DialWait", "tblPrefs")
'varDialWait = 8
Dim strMsg As String
Dim varReturn As Long, lngX As Long
strMsg = "You have 10 seconds to Pick up the Phone to Talk!" &
"..."
varReturn = SysCmd(acSysCmdInitMeter, strMsg, 10)
' Display message in status bar.
For lngX = 1 To 10
varReturn = SysCmd(acSysCmdUpdateMeter, lngX)
' Update meter.
Sleep 1000 ' sleep 1 second

Next lngX
varReturn = SysCmd(acSysCmdClearStatus)


'For x = 1 To 6
'Me.statusbar = "...... 6 seconds to Pick up the Phone"

'varStart = Timer
'Do While Timer < varStart + varDialWait
' DoEvents
'Hide_Window ("Call Status") '<<=== this fails with Error
Number 49: Bad DLL calling convention
' Loop
End If
Exit_Here:
blnDialing = False
Close_By_Caption ("Dialing") ' - works great
Close_By_Caption ("Call Status") '- works great
Close_By_Caption ("Phone Dialer") ' - does

'CloseAPP ("dialer.exe")
Exit Sub
HandleErr:
Select Case Err.Number
Case 94 'Invalid Use of Null - if double-click on blank, open
dialer
Call Shell("c:\windows\dialer.exe", vbNormalFocus)
Exit Sub
Case Else
'modHandler.LogErr ("frm0Telephone"),
("Telephone_Numbers_DblClick")
End Select
Resume Exit_Here
End Sub
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:eQ*******************@newssvr29.news.prodigy. com...
If you do not have SPY++ send me a functioning MDB and I'll post the
Class name for the Dialog.


Hi Stephen,

It's on it's way...

Thanks!


Nov 12 '05 #10
Very cool Dimitri!!
:-)

Though I would remove the credit to Walker... he get too much credit as
it is!<grin>
(Hi Peter)

--
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Dimitri Furman" <df*****@cloud99.net> wrote in message
news:Xn****************************@127.0.0.1...
On Apr 13 2004, 05:05 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WW****************@linvalid.com> wrote in news:lCYec.17978$Np3.635507@ursa- nb00s0.nbnet.nb.ca:
You can use SPY++ if you have VC++( or I think even VB) on your system to determine the Class name of the offending Dialog. Modify your code to find the window by Class name instead of Caption.


Or, if you don't have Spy++, you can use Wintree from
http://www.users.cloud9.net/~dfurman/code.htm

--
remove a 9 to reply by email


Nov 12 '05 #11
Thanks. The status bar meter is a nice touch. Appreciate the help.
You were passing a 0 which is interpreted as the memory location at
address ZERO.


SW_HIDE is supposed to hide the window - I thought SW_HIDE is a constant for
0... what then to pass?

Private Declare Function ShowWindow _
Lib "user32" _
( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long _
)

Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
ShowWindow hwnd, 0 '<<=== if not 0, then what?
End If
End Function

Private Sub HideCallStatus()
Hide_Window ("Call Status")
End Sub
Nov 12 '05 #12
For the ShowWindow API I said the second param should be declared as
Long not Integer.

The ByVal vs ByRef issue was for the PostMessage API declaration.

:-)
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:qL******************@newssvr29.news.prodigy.c om...
Thanks. The status bar meter is a nice touch. Appreciate the help.
You were passing a 0 which is interpreted as the memory location at
address ZERO.
SW_HIDE is supposed to hide the window - I thought SW_HIDE is a

constant for 0... what then to pass?

Private Declare Function ShowWindow _
Lib "user32" _
( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long _
)

Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
ShowWindow hwnd, 0 '<<=== if not 0, then what?
End If
End Function

Private Sub HideCallStatus()
Hide_Window ("Call Status")
End Sub


Nov 12 '05 #13
On Apr 13 2004, 09:16 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WW****************@linvalid.com> wrote in news:ci0fc.18208$Np3.641838@ursa-
nb00s0.nbnet.nb.ca:
Very cool Dimitri!!
:-)

Though I would remove the credit to Walker... he get too much credit as
it is!<grin>
(Hi Peter)


Thanks Stephen! I had too much time on my hands at one point <g>

Peter deserves the credit though - he posted something that gave me the
idea, so I started to fool with it, only to discover the existence of Spy++
a week after I was done with the thing... Well, at least it does delayed
window snapshots, which I don't think you can do with Spy++.

--
remove a 9 to reply by email
Nov 12 '05 #14
I know the feeling Dimitri!
:-)
Peter's posts have started several of my projects as well.
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Dimitri Furman" <df*****@cloud99.net> wrote in message
news:Xn****************************@127.0.0.1...
On Apr 13 2004, 09:16 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WW****************@linvalid.com> wrote in news:ci0fc.18208$Np3.641838@ursa- nb00s0.nbnet.nb.ca:
Very cool Dimitri!!
:-)

Though I would remove the credit to Walker... he get too much credit as it is!<grin>
(Hi Peter)

Thanks Stephen! I had too much time on my hands at one point <g>

Peter deserves the credit though - he posted something that gave me

the idea, so I started to fool with it, only to discover the existence of Spy++ a week after I was done with the thing... Well, at least it does delayed window snapshots, which I don't think you can do with Spy++.

--
remove a 9 to reply by email


Nov 12 '05 #15
I can't believe it, thought I was the google master and it took me 48hrs to find this forum. I have been trying to find exactly the same thing, some VB calls so I can code up an application to make my computer work like a speed dial on a $20 phone :-). Lots of hours into this, so can't stop now. I see many references to the tapiRequestMakeCall but I was having the same problem with it, the DIAL.EXE pops open so many windows that one may as well dial the number manually by the time you click so many screens closed.

I found Steven A. Fare's answering machine application
http://www.pscode.com/vb/scripts/Sho...32372&lngWId=1
but unfortunately it didn't do any dialing with TAPI, only answering. I couldn't find reference to the VB_TAPI.bas he used anywhere except in his answering machine code, so I assume that he authored, however the ID he has posted for contact no longer works. In this BAS TAPI definition module I did notice it has a lot of calls he doesn't use in his app; some of them sounded like they had potential but since I am a cut and paste WIN32API VB programmer, I can't make much headway with them. Interesting possibilities come from the sound of:

Public Declare Function lineOpen Lib "Tapi32" (ByVal hLineApp As Long, _
ByVal dwDeviceID As Long, ByRef lphLine As Long, ByVal dwAPIVersion As _
Long, ByVal dwExtVersion As Long, ByRef dwCallbackInstance As Long, _
ByVal dwPrivileges As Long, ByVal dwMediaModes As Long, _
ByRef lpCallParams As Long) As Long


Public Declare Function lineMakeCall Lib "Tapi32" (ByVal hLine As Long, _
ByRef lphCall As Long, ByVal lpszDestAddress As String, _
ByVal dwCountryCode As Long, ByVal lpCallParams As Long) As Long

Public Declare Function lineDrop Lib "Tapi32" (ByVal hCall As Long, _
ByVal lpsUserUserInfo As String, ByVal dwSize As Long) As Long

It would be nice to use TAPI without having to kill DIAL.EXE but for now, it appears as someone has gone to a lot of trouble to code a work-around so that DIAL.EXE can be killed after the dial.

So, next question, is the hard work of the postings and calculations above available anywhere in a single section of code, i.e. "DialNumber&KillDialExe.vbp"? Thanks!!!!!!!!!!!!!!

(It is hard for me to follow above as to which piece of corrected code overrides which in the original example.) THANKS AGAIN!
May 3 '06 #16
I created this in VB 6:


[HTML]
form1.frm:

Private Sub Command2_Click()
Call Telephone_Numbers_DblClick("5555")
End Sub

TAPI_KillDialExe.bas:

Option Explicit
Const WM_CLOSE = &H10
'Const SW_HIDE = 0

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'API use Phone Dialer to make call
Private Declare Function tapiRequestMakeCall Lib "TAPI32.DLL" _
(ByVal DestAddress As String, ByVal AppName As String, ByVal CalledParty As String, _
ByVal Comment As String) As Long

'API find applcation by full caption
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'API bring Window to foreground
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

'API set ShowWindow to hide window
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long)

'API send message to application
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Function Hide_Window(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd Then
Debug.Print hwnd
Debug.Print AppCaption
ShowWindow hwnd, 0
End If
End Function

Private Function Close_By_Caption(AppCaption As String)
Dim hwnd As Long
hwnd = FindWindow(vbNullString, AppCaption)
If hwnd <> 0 Then
'Bring to Front
SetForegroundWindow hwnd
'Close the app nicely
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
Exit_Here:
Exit Function
HandleErr:
Select Case err.Number
Case Else
'modHandler.LogErr ("frm0Telephone"), ("Close_By_Caption")
End Select
Resume Exit_Here
End Function

Private Function CloseAPP(AppNameOfExe As String, _
Optional KillAll As Boolean = False, _
Optional NeedYesNo As Boolean = True) As Boolean
Dim oProcList As Object
Dim oWMI As Object
Dim oProc As Object
CloseAPP = False
'create WMI object instance:
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
'create object collection of Win32 processes:
Set oProcList = oWMI.InstancesOf("win32_process")
'iterate through the enumerated collection:
For Each oProc In oProcList
'Debug.Print oProc.Name
'option to close a process:
If UCase(oProc.Name) = UCase(AppNameOfExe) Then
NeedYesNo = False 'don't wan't msgbox
If NeedYesNo Then
If MsgBox("Kill " & oProc.Name & vbNewLine & "Are you sure?", vbYesNo + vbCritical) = vbYes Then
oProc.Terminate (0)
CloseAPP = True
End If
Else
oProc.Terminate (0)
CloseAPP = True
End If
'continue search for more?
If Not KillAll And CloseAPP Then
Exit For 'oProc In oProcList
End If
End If
Next
Else
'report error
End If
Exit_Here:
Set oProcList = Nothing
Set oWMI = Nothing
Exit Function
HandleErr:
Select Case err.Number
Case Else
'modHandler.LogErr ("frm0Telephone"), ("Close_APP")
End Select
Resume Exit_Here
End Function

Public Sub Telephone_Numbers_DblClick(strDial As String)
On Error GoTo HandleErr
Dim varDialWait As Variant
Dim varStart As Variant
'Dim strDial As String
Dim lngRetVal As Long
Static blnDialing As Boolean 'prevent reentry into sub while dialing
DoEvents
blnDialing = False
If blnDialing Then Exit Sub
'strDial = Me.TelNumber
lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
If lngRetVal = 0 Then
blnDialing = True
'varDialWait = DLookup("DialWait", "tblPrefs")
'varDialWait = 8
Dim strMsg As String
Dim varReturn As Long, lngX As Long
strMsg = "You have 10 seconds to Pick up the Phone to Talk! ..."
' varReturn = syscmd(acSysCmdInitMeter, strMsg, 10)
' Display message in status bar.
For lngX = 1 To 10
' varReturn = syscmd(acSysCmdUpdateMeter, lngX)
' Update meter.
Sleep 1000 ' sleep 1 second
Next lngX
' varReturn = syscmd(acSysCmdClearStatus)
' 'For x = 1 To 6
'Me.statusbar = "...... 6 seconds to Pick up the Phone"
'varStart = Timer
'Do While Timer < varStart + varDialWait
' DoEvents
'Hide_Window ("Call Status") '<<=== this fails with Error Number 49: Bad DLL calling convention
' Loop

End If
Exit_Here:
blnDialing = False
Close_By_Caption ("Dialing") ' - works great
Close_By_Caption ("Call Status") '- works great
Close_By_Caption ("Phone Dialer") ' - does

'CloseAPP ("dialer.exe")
Exit Sub
HandleErr:
Select Case err.Number
Case 94 'Invalid Use of Null - if double-click on blank, open dialer
Call Shell("c:\windows\dialer.exe", vbNormalFocus)
Exit Sub
Case Else
'modHandler.LogErr ("frm0Telephone"),("Telephone_Numbers_DblClick" )
End Select
Resume Exit_Here
End Sub

[/HTML]
From the above, I still get two popup menus:

1) Lift the receiver and talk (Hangup/Talk options)
2) You are currently in a call. Are you sure you want to quit? (Yes/No opt)

So it is better but still all the menus are not hidden. I still see the two "slider" menus that pop up in the upper left had of the screen from the DIAL.EXE.

P.S. I stepped through the process above and see that this function call did not find anything:
=> Close_By_Caption("Dialing")

P.S.S. A nit, but DIAL.EXE might not be in [inst drive]\windows, maybe on another drive and maype ?:\WINNT
May 3 '06 #17
I am calling this from VB6 but I stuck to Win32 menu controls instead of internal VB calls like SendKeys in hopes that someone could use this as a base to insert into their VBA application.

Anyway, as I said I don't know much about coding the API and below is cut and paste hacking, but when I use it at least it closes all the Dialer windows after 10 seconds. Still I wish I could find something online where someone uses a more basic routine from the tapi library than this pesky tapiRequestMakeCall - "dialer.exe" crazed menu intensive wrappper.

[HTML]Option Explicit
Const WM_CLOSE = &H10
Const WM_DESTROY = &H2
'Const SW_HIDE = 0
Const WM_SETTEXT = &HC
Const WM_COMMAND = &H111
Const VK_RETURN = &HD
Const WM_CHAR = &H102
Const WM_KEYDOWN = &H100
Const WM_KEYUP = &H101
Const VK_SPACE = &H20

Const GW_CHILD As Long = 5
'Const WM_CHAR = 258
Const VK_F10 = &H79
Const VK_F5 = &H74
Const VK_L = &H4C


Const SW_HIDE = 0
Const SW_SHOW = 5

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


'API use Phone Dialer to make call
Private Declare Function tapiRequestMakeCall Lib "TAPI32.DLL" _
(ByVal DestAddress As String, ByVal AppName As String, ByVal CalledParty As String, _
ByVal Comment As String) As Long

'API find applcation by full caption
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'API bring Window to foreground
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

'API set ShowWindow to hide window
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long)

'API send message to application
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long

Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) 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 Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000


Public Sub Telephone_Numbers_DblClick(strDial As String)
On Error GoTo HandleErr
Dim varDialWait As Variant
Dim varStart As Variant
Dim lThreadId As Long, lProcessId As Long, ret As Long
'Dim strDial As String
Dim lngRetVal As Long
Static blnDialing As Boolean 'prevent reentry into sub while dialing
DoEvents
blnDialing = False
If blnDialing Then Exit Sub
'strDial = Me.TelNumber
Form1.Label6.Caption = "Calling TAPI ..."

lngRetVal = tapiRequestMakeCall(Trim$(strDial), "", "", "")
If lngRetVal = 0 Then
blnDialing = True

Dim strMsg As String
Dim varReturn As Long, lngX As Long
Form1.Label1.Caption = "You have 10 seconds to Pick up the Phone to Talk! ..."

For lngX = 1 To 10
Form1.Label6.Caption = "Waiting " & 11 - lngX & " ..."
DoEvents
Sleep 1000 ' sleep 1 second
Next lngX
Form1.Label6.Caption = "Ready for next call ..."

End If
Exit_Here:
hwnd = FindWindow(vbNullString, "Call Status")
If hwnd <> 0 Then
Call SendMessage(hwnd, WM_CLOSE, 0&, 0&)
End If
hwnd = FindWindow(vbNullString, "Phone Dialer")
If hwnd <> 0 Then
PostMessage hwnd, WM_CLOSE, 0&, 0&
End If
'
hwnd = FindWindow(vbNullString, "Dialer")
If hwnd <> 0 Then
PostMessage hwnd, WM_KEYDOWN, VK_RETURN, 0
PostMessage hwnd, WM_KEYUP, VK_RETURN, 0
End If

Exit Sub
HandleErr:
Select Case err.Number
Case 94 'Invalid Use of Null - if double-click on blank, open dialer
MsgBox "here" 'Call Shell("c:\windows\dialer.exe", vbNormalFocus)
Exit Sub
Case Else
'modHandler.LogErr ("frm0Telephone"),("Telephone_Numbers_DblClick" )
End Select
'Resume Exit_Here
End Sub[/HTML]
May 4 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: deko | last post by:
The below code dials a phone number when the subform datasheet cell containing the number is double clicked. The problem is that the dialer application (c:\windows\dialer.exe) pops up windows on...
0
by: MrNobody | last post by:
hey guys... I'm trying to make my DataGrid have selection behavior similar to WindowsExplorer, where I can hold CTRL to add rows to a multi-row selection. Thanks to someone else on this...
9
by: Lonnie Princehouse | last post by:
There doesn't seem to be any way to customize the behavior of "is" as can be done for other operators... why not?
6
by: raj | last post by:
Hi every one I am working on a vb.net, windows application and i am not able to figure out how to change the deployment project settings so that i can change the installation and un-installation...
8
by: Dustan | last post by:
Can I make enumerate(myObject) act differently? class A(object): def __getitem__(self, item): if item 0: return self.sequence elif item < 0: return self.sequence elif item == 0: raise...
1
by: Ryou kaihou | last post by:
As we known, in Visual Stdio 2003 or 2005, the property of Autosize of Label is set to True by defaut, how can I customize this and set property of Autosize to False? Any ideas? Thanks
5
by: DLN | last post by:
Getting rid of the Customize option. I want to get rid of the {Right-Click}-{Customize} option on the tool bars. I’ve been able to get rid of all the other options but not Customize itself. ...
0
by: Shailesh Patel | last post by:
I am having a small VB application to call customers through my laptop. I use tapiRequestMakeCall for this to make calls using a modem. I have to problems where I need help from someone expert on...
0
Iman100
by: Iman100 | last post by:
Hi I have quiz (MCQ) data stored in my Database. I need to customize the question view to show the question then use RadioButtonList to display my choices. Is there is any tutorial or guide I can...
0
by: Sky | last post by:
I have an Access 2003 front-end database with custom toolbars. The toolbars work fine. One annoying feature is that at the far right edge of each custom toolbar there a small dropdown arrow....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.