Trapping Escape

Discussion in 'AutoCAD' started by Nathan Guill, May 11, 2004.

  1. Nathan Guill

    Nathan Guill Guest

    I know this has been asked before, in fact I've asked it before, but I need
    to find out if anyone knows how to trap the escape key.

    I have this routine that will place objects onto certain layers depending
    upon the command used (i.e. Dimensions on the Dim layer, Hatches on the
    Hatch layer, etc.) and then return the user to the layer they were on before
    running the command. The problem is when the user escapes the command.

    Any ideas?
     
    Nathan Guill, May 11, 2004
    #1
  2. Nathan Guill

    bcoward Guest

    Nathan,

    Here is an example on how the GetAsyncKeyState API can be used. You would handle this in the KeyPress event

    Declare Function GetAsyncKeyState Lib "user32" Alias _
    "GetAsyncKeyState" (ByVal vKey As Long) As Integer


    If GetAsyncKeyState(vbKeyEscape) <> 0 Then
    'User pressed the Escape key
    MsgBox "User Cancelled..."
    End If

    Hope this get you moving in the desired direction.

    Good luck,

    Bob Coward
    CADS, Inc

    800-366-0946
     
    bcoward, May 11, 2004
    #2
  3. Nathan Guill

    Nathan Guill Guest

    Just to make certain, and because I didn't specify in my original email...

    I am executing this routine in the AcadDocument_BeginCommand and
    AcadDocument_EndCommand events. I did not see a KeyPress event for
    AcadDocument (I know that it doesn't always mean anything), do I put this in
    AcadDocument_KeyPress? Thanks for your help.


    handle this in the KeyPress event
     
    Nathan Guill, May 11, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.