SendCommand??????

SendCommand??????

Anonymous
Not applicable
292 Views
5 Replies
Message 1 of 6

SendCommand??????

Anonymous
Not applicable
I want to send a command to AutoCad R.14.01 from VB6. How can I accomplish
this?

Cheers, John.
0 Likes
293 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
You can use the flaky SendKeys method or use AcadUnSupp. I've never tried it
myself but there should be a copy somewhere in the Customer Files NG.

John McDowell wrote in message
news:[email protected]...
> I want to send a command to AutoCad R.14.01 from VB6. How can I accomplish
> this?
>
>
> Cheers, John.
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
I get an error using the above code.
I do not think that stand alone VB6 has a "ThisDrawing" object
0 Likes
Message 4 of 6

Anonymous
Not applicable
Paste this code into a module and give it a try.

Option Explicit
Option Compare Text
Public Const WM_COPYDATA = &H4A
Type CopyStringDataStruct
dwData As Long
cbData As Long
lpData As String
End Type
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As
Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As
Long

Public Sub SndCmd(Cmd As String)
Dim n As Integer, ch As String, Cmd2 As String
Dim WinMsg As CopyStringDataStruct
Dim hWnd As Long
Cmd2 = ""
For n = 1 To Len(Cmd)
ch = Mid$(Cmd, n, 1)
If ch = "^" Then
n = n + 1
If n <= Len(Cmd) Then
ch = StrConv(Mid$(Cmd, n, 1), vbUpperCase)
ch = Chr$(Asc(ch) - 64)
Else
ch = ""
End If
End If
Cmd2 = Cmd2 & ch
Next n
If Cmd2 <> "" Then
Cmd2 = Cmd2 & vbNullChar
hWnd = FindWindow(vbNullString, ThisDrawing.Application.Caption)
If hWnd <> 0 Then
WinMsg.dwData = CLng(1)
WinMsg.cbData = Len(Cmd2) + 1
WinMsg.lpData = Cmd2
SendMessage hWnd, WM_COPYDATA, hWnd, WinMsg
Else
MsgBox "Could Not Find AutoCAD Window."
End If
End If
End Sub

-Josh

John McDowell wrote:

> I want to send a command to AutoCad R.14.01 from VB6. How can I accomplish
> this?
>
> Cheers, John.
0 Likes
Message 5 of 6

Anonymous
Not applicable
Oops,
Try using the caption of the app you retrieve with "getobject" or
"createobject".
sorry,
-Josh

badgers wrote:

> I get an error using the above code.
> I do not think that stand alone VB6 has a "ThisDrawing" object
0 Likes
Message 6 of 6

Anonymous
Not applicable
John,

Goto http://vbdesign.hypermart.net/sources/ and download the premiere issue
of Sources. In it you will find and article that addresses your specific
question. If you have anything further after reading this article please
email me directly at [email protected].

Joe Sutphin
Author of "AutoCAD 2000 VBA Programmers Reference"
ISBN #1861002564 Order it at
http://www.amazon.com/exec/obidos/ASIN/1861002564/o/qid%3D942504788/sr%3D8-1
/002-7788324-2908264

Checkout Sources - the only magazine dedicated to AutoCAD customization
http://vbdesign.hypermart.net/sources/

John McDowell wrote in message
news:[email protected]...
> I want to send a command to AutoCad R.14.01 from VB6. How can I accomplish
> this?
>
>
> Cheers, John.
>
>
0 Likes