2

I am using a few custom commands in AutoCAD that use the SendKeys command. Recently this started to turn on and off my Caps Lock and Num Lock and is somewhat unpredictable so I am looking for an alternative to the SendKeys command.

What can I use that would have the same result?

The code allows me to copy an object and paste it multiple times.

Sub CopyMultiple()
    SendKeys "MULTIPLE" & Chr(13) & "COPY" & Chr(13)
End Sub
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
M.T.
  • 31
  • 2
  • So in AutoCAD, you would type `"MULTIPLE" [Enter] "COPY" [Enter]` to do it (not shortcuts)? Normally when you involve line feeds/carriage return, should you wait a little in between? I previously used SendKey to automate a lot of keystrokes to invoke a software to do a backup. And times similar issue arises and to resolve it, I have to slow down - putting pauses when a popup window is expected. – PatricK Apr 06 '17 at 23:02
  • Sorry, I should have specified that. I hit [C] [M] [SPACE] which triggers the code. It worked for me for a year and then suddenly a week or two ago it started messing with my caps lock. There are a couple other commands with shortcuts that I rarely use that also use SendKeys so I was able to verify that Sendkeys is the issue. Other people in my department using the same shortcuts do not have the issue. – M.T. Apr 07 '17 at 01:26
  • Do you use [`.AppActivate()`](https://msdn.microsoft.com/en-us/library/dyz95fhy(v=vs.90).aspx)? Using same language on Windows? You can extract those lines of Shell and SendKeys to new .vbs file and test disregarding the AutoCAD? – PatricK Apr 07 '17 at 04:36
  • I'm not sure if I follow what you are saying. Do you mean try it in another program that uses VBA, like Excel? – M.T. Apr 07 '17 at 12:41

1 Answers1

1

This functionality is already built into AutoCAD:

Either set the COPYMODE system variable to 0, or use the mOde option as part of the standard COPY command to change this system variable from within the command:

Command: COPY
Select objects: 1 found    
Current settings:  Copy mode = Multiple
Specify base point or [Displacement/mOde] <Displacement>: O
Enter a copy mode option [Single/Multiple] <Multiple>:
Lee Mac
  • 15,615
  • 6
  • 32
  • 80