.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Capture Random Input with GetPoint

4 REPLIES 4
Reply
Message 1 of 5
ChrisPicklesimer
374 Views, 4 Replies

Capture Random Input with GetPoint

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

 

4 REPLIES 4
Message 2 of 5
jeff
in reply to: ChrisPicklesimer

I have done with Application.PreTranslateMessage

You can also find your answers @ TheSwamp
Message 3 of 5
ChrisPicklesimer
in reply to: jeff

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

Message 4 of 5

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

Message 5 of 5

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost