Page 1 of 2

Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 2:03 pm
by jvalencia
Hello, I'm trying to send a keypress to the UCCNC window but it always ignore my command.

Other apps/windows receive the keypress just well.

What I did is to use the "nircmd" utility to activate the window and then send the key combination, like this:

Code: Select all
nircmdc.exe win activate stitle "UCCNC" & nircmdc.exe sendkeypress shift+1


In UCCNC I configured shift+1 to set the reset button on.

I suspect this has to do with the programming environment of UCCNC, it isn't respecting windows events or something.

Re: Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 2:07 pm
by cncdrive
The UCCNC handles keyevents on the lowest Windows level so other softwares can't mess up the key events in case they change key registrations.
The low level Windows API for keypress handling which the UCCNC uses is the following:

Code: Select all
[DllImport("user32.dll")]
        public static extern int GetKeyboardState(byte[] keystate);

Re: Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 2:54 pm
by jvalencia
ahm, I'm out of luck then.

Thanks

Re: Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 3:02 pm
by dezsoe
What do you want to do? Maybe, if you tell us what you want to do, we can recommend a way to do it.

Re: Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 5:02 pm
by jvalencia
dezsoe wrote:What do you want to do? Maybe, if you tell us what you want to do, we can recommend a way to do it.


I made a simple pendant using an arduino and the modbus plugin.

In my test machine under vmware, it works perfect, for hours without problem.

In my production machine, a laptop with windows 7, the pendant stops working after 10-15 minutes. The debug window shows a timeout and that's all.

The UCCNC version is the same in both systems and the modbus configuration is the same also.

Without more verbose debug, I don't know what's happening. That's why I tried another route, using usb-serial and use a simple ruby script that sends keypresses to UCCNC for those events.

But UCCNC ignores part of those keys.

My last hope is using an arduino micro and emulating a usb keyboard.

It would be great if UCCNC had some sort of IPC system to communicate with it.

Re: Sending a keypress to UCCNC

PostPosted: Wed Aug 08, 2018 5:22 pm
by dezsoe
OK. Maybe, you could write a plugin to communicate with the Arduino and then you have everything in your hands. The plugin can be written in any .Net language and there are samples (C# and Visual Basic) in the Plugins folder. The plugin can also communicate with UCCNC, e.g. send keys or do anything else.

If it is a serial application: when the communication stops, did you check if the serial port still exists? It is possible, that it's a USB problem. Or, it can be a USB power problem if the Arduino is USB powered.

Re: Sending a keypress to UCCNC

PostPosted: Thu Aug 09, 2018 7:41 am
by kawarider
Arduino Leonardo and Clickbutton. I was just reading some topic of someone that build a pendent that way. Leonardo because that has a 32u4 chip inside that can emulate a keybord. Very interesting and looks very simple. I don t know anything, but it might help you.

https://www.hackster.io/edr1924/arduino ... ant-aefa13

Re: Sending a keypress to UCCNC

PostPosted: Fri Aug 10, 2018 3:50 pm
by jvalencia
Ok, I got an Arduino Micro working as intended.

I assigned macros to hotkeys and the arduino actually sends the key presses.

BUT....

uccnc refuses to execute a macro while the cycle is running.

Is there a way to force a macro to be executed even when cycle is running?

I just want to change the feed speed while it's running.

Re: Sending a keypress to UCCNC

PostPosted: Fri Aug 10, 2018 4:04 pm
by ger21
Can you use a macroloop?

Re: Sending a keypress to UCCNC

PostPosted: Fri Aug 10, 2018 4:30 pm
by jvalencia
ger21 wrote:Can you use a macroloop?


a macroloop means that I have to learn C# to code a serial protocol to interface with the arduino :|

if it just allowed macros to run while cycle is active...