.NET

Reply
Valued Contributor
Chris.Picklesimer
Posts: 89
Registered: ‎04-07-2000
Message 1 of 5 (171 Views)

Capture Random Input with GetPoint

171 Views, 4 Replies
03-14-2014 01:25 PM

Is there any way to capture what a user enters from keyboard during Getpoint?  I see where I can set

 

prPointOptions.AllowNone = True

 

and then be able determine if a user hit Enter.  I would like to be able to capture any random input.

 

Is this possible?

 

Thanks

 

Chris

 

Valued Mentor
jeff
Posts: 327
Registered: ‎05-12-2009
Message 2 of 5 (162 Views)

Re: Capture Random Input with GetPoint

03-14-2014 02:10 PM in reply to: Chris.Picklesimer

I have done with Application.PreTranslateMessage

You can also find your answers @ TheSwamp
Valued Contributor
Chris.Picklesimer
Posts: 89
Registered: ‎04-07-2000
Message 3 of 5 (114 Views)

Re: Capture Random Input with GetPoint

03-17-2014 07:15 AM in reply to: jeff

I have never used that before.  Would you have an example?  Thanks.

ADN Support Specialist
philippe.leefsma
Posts: 617
Registered: ‎06-02-2009
Message 4 of 5 (106 Views)

Re: Capture Random Input with GetPoint

03-17-2014 08:04 AM in reply to: Chris.Picklesimer

Here is an example that illustrates two approaches, the one Jeff mentioned and the message filter. I'm not sure if one is better than the other, you find out.

 

I'm curious to know what kind of feature you want to implement, usually one will use keywords rather than grabbing raw keyboard inputs ...

 

const int WM_KEYDOWN = 0x0100;
        
[CommandMethod("AppMsg")]
public void AppMsg()
{
    Application.PreTranslateMessage += 
        new PreTranslateMessageEventHandler(Application_PreTranslateMessage);

    appMsgFilter = new AppMessageFilter();
    System.Windows.Forms.Application.AddMessageFilter(appMsgFilter);

    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;

    var pr = doc.Editor.GetPoint("\nGet Point: ");

    System.Windows.Forms.Application.RemoveMessageFilter(appMsgFilter);

    Application.PreTranslateMessage -=
        new PreTranslateMessageEventHandler(Application_PreTranslateMessage);
}

void Application_PreTranslateMessage(
object sender,
PreTranslateMessageEventArgs e) { System.Windows.Interop.MSG msg = e.Message; if (msg.message == WM_KEYDOWN) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; doc.Editor.WriteMessage("\nKey: " + msg.wParam); } } static AppMessageFilter appMsgFilter = null; class AppMessageFilter : System.Windows.Forms.IMessageFilter { public bool PreFilterMessage(ref System.Windows.Forms.Message m) { if (m.Msg == WM_KEYDOWN) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; doc.Editor.WriteMessage("\nKey: " + m.WParam); } return false; } }

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Valued Contributor
Chris.Picklesimer
Posts: 89
Registered: ‎04-07-2000
Message 5 of 5 (101 Views)

Re: Capture Random Input with GetPoint

03-17-2014 08:23 AM in reply to: philippe.leefsma

Thanks.  I'll check it out.  I am trying combine GetPoint with GetInt or Getstring.  When a user is prompted for a point I want to check for three things: 1)valid point, 2) enter or 3) random integer/string input.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.