Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trap the Escape key from within AddIn

5 REPLIES 5
Reply
Message 1 of 6
larry.daubenspeck
676 Views, 5 Replies

Trap the Escape key from within AddIn

Can someone please show me an event handler (or whatever is needed) for bailing out of an AddIn?  I'm using VB.net.  The end users would prefer to use the ESCAPE key for this.  Many thanks!

Larry Daubenspeck
Software Programmer
Draper, Inc.
5 REPLIES 5
Message 2 of 6

Hi,

 

Not sure how is your workflow, but have your tried with KeyDown of the dialog of your add-in? something like below:

 

Private Sub MyForm_KeyDown( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown

 

' shortcut ESC key
If e.KeyCode = Keys.Escape Then
    'do what you need
End If

End Sub

Message 3 of 6

Thanks for that.  However, this particular addin doesn't use a dialog.  Once launched, it iterates through all the components, finds pulleys, creates a path, and finally sweeps a cable into existence.

Larry Daubenspeck
Software Programmer
Draper, Inc.
Message 4 of 6
imvu
in reply to: larry.daubenspeck

Is your question how to let users cancel a long-running operation?

As in, you want to show a progress bar, and if the user presses escape, the operation stops?

This thread on Stack Overflow uses native interop (DllImport) to test key state:

http://stackoverflow.com/questions/3829725/winforms-retrieve-keyboard-state-without-form-usercontrol

You probably want to integrate with the built-in progress bar in Inventor though.

Message 5 of 6

Hi,

 

sounds like you just want to trap the key events of Inventor? If yes, InteractionEvents.KeyboardEvents can help. API help reference has some code demos.

Message 6 of 6

Thanks...I'll give that a whirl sometime.

Larry Daubenspeck
Software Programmer
Draper, Inc.

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

Post to forums  

Autodesk Design & Make Report