How to accept a Jig keyword without entering an extra space key or enter key

How to accept a Jig keyword without entering an extra space key or enter key

Miralkong
Advocate Advocate
517 Views
3 Replies
Message 1 of 4

How to accept a Jig keyword without entering an extra space key or enter key

Miralkong
Advocate
Advocate

I'm using Jig for a block reference insertion. Everything is fine except that I have to enter an extra space key or enter key to let AutoCAD know that the keyword has been entered completely.

I find another application which sets all keywords with only one letter. In that case, when users finish typing the letter(without space key or enter key), the application could respond immediately.

Base on the application's UI, I guess the message and keywords settings are as follow:

JigPromptPointOptions jigOpts = new JigPromptPointOptions();

jigOpts.UserInputControls = (
    UserInputControls.Accept3dCoordinates
  | UserInputControls.NoZeroResponseAccepted
  | UserInputControls.NoNegativeResponseAccepted);

jigOpts.SetMessageAndKeywords("\nSpecify intertion point[Rotate90(A)/HFlip(S)/VFlip(D)/ChangeBasePt(T)]", "A S D T");

But I could not figure out how to eliminate the space key or enter key.  Could someone help? Thanks.

 

0 Likes
518 Views
3 Replies
Replies (3)
Message 2 of 4

ActivistInvestor
Mentor
Mentor

I think the only way to do that is to monitor keystrokes using a message filter.

0 Likes
Message 3 of 4

Miralkong
Advocate
Advocate
Thanks for reply. It seems promising. I added some code like below:

 

private class JigFilter : IMessageFilter
        {
            const int WM_KEYDOWN = 0x0100;
            public bool PreFilterMessage(ref Message m)
            {
                Autodesk.AutoCAD.ApplicationServices.Document acDoc = AcadApp.DocumentManager.MdiActiveDocument;
                Editor acEditor = acDoc.Editor;
                if (m.Msg == WM_KEYDOWN && (Keys)m.WParam == Keys.A)
                {
                    acEditor.WriteMessage("A ");
                    //acEditor.WriteMessage("A\n");
                    return true;
                }
                return false;
            }
        }

 

It did catch the A keystroke. However when I tried to send "A " or "A\n" back to the dragging. The Drag status is PromptStatus.Other instead of PromptStatus.Keyword and the StringResult is null. I believe there are other ways to send the message back to keyword. Could you give me more specific instructions? Thanks.
Message 4 of 4

braistorm
Explorer
Explorer

you can catch the keydown message,if the message is expected then send enter to the command line or using keybd_event to  emulate 'enter'.

 

Another way to catch the keydown   messgae is using Application.PreTranslateMessage, see    https://www.cnblogs.com/chenshuangjian/p/15958356.html

0 Likes