Request guidance on Winform Rhino interaction

Hello, please ask me a question that has puzzled me for a long time. How to close my form by pressing Enter or Esc when the focus is in Rhino. I found that only when my form has focus, can I close (execute) by pressing Enter. My wish is just like Sweep2 in Rhino. Pressing Enter will execute.

This is my mode form: form. ShowSemiModal (RhinoWinApp. MainWindow);

Thanks again.

Hi @Huang,

This probably isn’t possible with WinForms without hooking the Windows keyboard.

– Dale

Thank you for taking some time out of your busy schedule to help me. It’s a pity, but at least I don’t need to look for information and search for topics related to the forum. I will use the keyboard hook according to your suggestions. thank you.

Actually you can.
There are 2 solutions :
-Standard windows api to detect when the keyboard is pressed
-If Rhino blocks some windows api (I don’t think It does), or if it fails on winforms from Rhino, you can simply run a subprocess or download&execute a subprogram in /temp/, when the specified key is pressed it changes the state on the winform you need and triggers the button pressed event.

By default Rhino does not interact with your WinForms, however you can 100% use winapi directly or indirectly to trigger the function you need, when the key you need is pressed.

There are plenty of solutions.
If you need any help message me.

Thank you very much for your advice. I’m using keyboard hooks to implement it. I think it should be feasible. Thank you again for your kind advice.

1 Like