Have my own grab function for hotkeys

If you created a new screenset and want to share it with others then please post it here. You can talk about screens here.

Have my own grab function for hotkeys

Postby shad » Wed Oct 18, 2017 7:39 pm

Balazs, Is it possible to add my own function in to the grab function code list for hotkeys? For example I need to have my handler for arrow keys (37,38,39,40) and jogs.
And second question - jog in the step mode use Fset feedrate. How I can manually change this feedrate?
Thank you!
-- Andrew
UC400ETH
UC300ETH-5LPT
NEURON Lite THC
http://neuroncnc.com/
shad
 
Posts: 268
Joined: Thu Sep 15, 2016 5:23 pm

Re: Have my own grab function for hotkeys

Postby cncdrive » Wed Oct 18, 2017 8:59 pm

Originally when we started developing the UCCNC to be generic we thought about handling these things like the button calls also generic.
A good example for that is the keypress event in C#, that you can cancel the event with e.Cancel and handle it with your own code.
Finally we dropped this idea, because it could cause so much confusion and problems.
Just think about what would happen if more than one plugins try to cancel the event and run it's own function on it, this could create serious conflicts and issues, so we did not make this possible.

What you could do in this particular case, if you want to do your own thing on joghotkeys is to remove the hotkeys from the hotkeys settings, so the UCCNC will then not do anything on button presses.
And then you could write your own handlers in the plugin.
However this could still create issues if the user will have the hotkeys enabled and so the UCCNC will do it's things on the hotkeys and you will do other things in the plugin.
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

Re: Have my own grab function for hotkeys

Postby shad » Thu Oct 19, 2017 6:26 am

I am understand you.
Just I am planned to temporally turn off hotkeys for RipCut future and then turn on.
I hope it's will be not very issue.
Thank you!
-- Andrew
UC400ETH
UC300ETH-5LPT
NEURON Lite THC
http://neuroncnc.com/
shad
 
Posts: 268
Joined: Thu Sep 15, 2016 5:23 pm

Re: Have my own grab function for hotkeys

Postby shad » Wed Jul 18, 2018 7:34 pm

Balazs, please tell me, how I can check in macro - keyboard key is pressed or not ?
Is it possible?
Thank you!
-- Andrew
UC400ETH
UC300ETH-5LPT
NEURON Lite THC
http://neuroncnc.com/
shad
 
Posts: 268
Joined: Thu Sep 15, 2016 5:23 pm

Re: Have my own grab function for hotkeys

Postby cncdrive » Thu Jul 19, 2018 12:02 am

Andrew,

I'm not sure what you want to do, but here is an example of attaching a keypress event handler to the mainform of the UCCNC and then when the Space key is pressed then show a messagebox and remove the event handler.

Code: Select all
exec.mainform.KeyPress += new System.Windows.Forms.KeyPressEventHandler(my_KeyPress);

#Events

private void my_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
  if((e.KeyChar == (char)Keys.Space))
  {
    exec.mainform.KeyPress -= new System.Windows.Forms.KeyPressEventHandler(my_KeyPress);
    MessageBox.Show("Space key was pressed!");
  }
}
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

Re: Have my own grab function for hotkeys

Postby shad » Thu Jul 19, 2018 8:01 am

Thank you Balazs!
Tell me please, can I use this event of the main form of the program in the plugin?
Or may be there is a way to make it via some method?
Just I want to be able to know in the plugin that I have pressed (hold) a certain button on the keyboard.
Thank you!
-- Andrew
UC400ETH
UC300ETH-5LPT
NEURON Lite THC
http://neuroncnc.com/
shad
 
Posts: 268
Joined: Thu Sep 15, 2016 5:23 pm

Re: Have my own grab function for hotkeys

Postby cncdrive » Thu Jul 19, 2018 8:59 am

Hi Andrew,

You don't have access to the mainform in plugins, but you could make your own form and grab the keypresses via that.
Or you could use a Windows API to get the keypresses, e.g.:

Code: Select all
[DllImport("user32.dll")]
        public static extern int GetKeyboardState(byte[] keystate);
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

Re: Have my own grab function for hotkeys

Postby shad » Thu Jul 19, 2018 10:49 am

Thank you Balazs!
It's clear for me now.
-- Andrew
UC400ETH
UC300ETH-5LPT
NEURON Lite THC
http://neuroncnc.com/
shad
 
Posts: 268
Joined: Thu Sep 15, 2016 5:23 pm


Return to Custom Screensets

Who is online

Users browsing this forum: No registered users and 2 guests