Code Red > VB(A)

SendKeys to Dialog Box

(1/2) > >>

MSTG007:
I have this vba code that I use to use with AutoCAD 2015. It was able to activate a command in autocad that would bring up a dialog box. Then it would proceed with the sendkeys on that dialog box.

I am trying the same thing in 2018 and the sendkeys do not work on the dialog box. However, when I close the dialog box, it runs the sendkeys at the command line. Not quite sure whats going on.

Thank you for any help!


--- Code: ---Sub Catchment()

 On Error Resume Next
 Set AcadApp = GetObject(, "AutoCAD.Application")
 If Err Then
 Err.Clear
 Set AcadApp = CreateObject("AutoCAD.Application")
 End If

 AppActivate AcadApp.Caption
 AcadApp.Visible = True
 AcadApp.Application.WindowState = acNorm
 AcadApp.ActiveSpace = acModelSpace


 If AcadApp.Documents.Count = 0 Then
 AcadApp.Documents.Add
 End If

 AcadApp.ActiveDocument.SendCommand "_CREATECATCHMENTFROMOBJECT" & vbCr
 

End Sub


Sub Catchment_Storm_SendKeys()
   Dim myApp As String

DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}", True

End Sub

--- End code ---

MSTG007:
lol. This is funny. I did not realized I asked this a few years ago.

http://www.theswamp.org/index.php?topic=49598.msg547399#msg547399

MP:
lulz. Cue the "I have alzheimer's but at  least I don't have alzheimer's" memes.

Back to your issue -- is it a case of modal vs non-modal -- i.e. it would work properly in the latter?

MSTG007:
It is modal. I have to click the OK button to dismiss it.

MSTG007:
Is there a way I can change a focus to the dialog box by targeting the title in the dialog box?

Navigation

[0] Message Index

[#] Next page

Go to full version