Author Topic: Trouble with SendKeys  (Read 3221 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 184
Trouble with SendKeys
« on: December 02, 2013, 05:27:16 PM »
I can't make SendKeys work for simulating CTRL+C.  I have tried :
SendKeys.Send("^(c)");
SendKeys.Send("^(C)");
SendKeys.Send("^c");
SendKeys.Send("^C");
Also tried with SendKeys.SendWait but with no success.
Also tried InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
Any help ? :|

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Trouble with SendKeys
« Reply #1 on: December 02, 2013, 06:18:53 PM »
requires .NET 4.0
Code - C#: [Select]
  1.         public static void SendCommand(this Document doc, string command)
  2.         {
  3.             dynamic acadDoc = doc.GetAcadDocument();
  4.             acadDoc.SendCommand(command);
  5.         }
  6.  
  7.         public static void SendCancel(this Document doc)
  8.         {
  9.             doc.SendCommand("\x03\x03");
  10.         }
  11.  

Have not tested but I think VB equivalent would be

Code - Visual Basic: [Select]
  1. Imports System
  2. Imports Autodesk.AutoCAD.Runtime
  3. Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension
  4. Imports Autodesk.AutoCAD.DatabaseServices
  5. Imports Autodesk.AutoCAD.Geometry
  6. Imports Autodesk.AutoCAD.EditorInput
  7.  
  8. Module Module1
  9.     <System.Runtime.CompilerServices.Extension> _
  10.     Public Sub SendCommand(doc As Document, command As String)
  11.         Dim acadDoc = doc.GetAcadDocument()
  12.         acadDoc.SendCommand(command)
  13.     End Sub
  14.  
  15.     <System.Runtime.CompilerServices.Extension> _
  16.     Public Sub SendCancel(doc As Document)
  17.         doc.SendCommand(ChrW(3) & ChrW(3))
  18.     End Sub
  19. End Module
  20.  
« Last Edit: December 02, 2013, 06:29:17 PM by Jeff H »