Sending a keypress to UCCNC

If you have a question about the software please ask it here.

Sending a keypress to UCCNC

Postby jvalencia » Wed Aug 08, 2018 2:03 pm

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.
jvalencia
 
Posts: 19
Joined: Fri Apr 13, 2018 4:43 pm

Re: Sending a keypress to UCCNC

Postby cncdrive » Wed Aug 08, 2018 2:07 pm

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);
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: Sending a keypress to UCCNC

Postby jvalencia » Wed Aug 08, 2018 2:54 pm

ahm, I'm out of luck then.

Thanks
jvalencia
 
Posts: 19
Joined: Fri Apr 13, 2018 4:43 pm

Re: Sending a keypress to UCCNC

Postby dezsoe » Wed Aug 08, 2018 3:02 pm

What do you want to do? Maybe, if you tell us what you want to do, we can recommend a way to do it.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Sending a keypress to UCCNC

Postby jvalencia » Wed Aug 08, 2018 5:02 pm

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.
jvalencia
 
Posts: 19
Joined: Fri Apr 13, 2018 4:43 pm

Re: Sending a keypress to UCCNC

Postby dezsoe » Wed Aug 08, 2018 5:22 pm

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.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Sending a keypress to UCCNC

Postby kawarider » Thu Aug 09, 2018 7:41 am

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
kawarider
 
Posts: 42
Joined: Sun Jun 17, 2018 10:38 am

Re: Sending a keypress to UCCNC

Postby jvalencia » Fri Aug 10, 2018 3:50 pm

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.
jvalencia
 
Posts: 19
Joined: Fri Apr 13, 2018 4:43 pm

Re: Sending a keypress to UCCNC

Postby ger21 » Fri Aug 10, 2018 4:04 pm

Can you use a macroloop?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: Sending a keypress to UCCNC

Postby jvalencia » Fri Aug 10, 2018 4:30 pm

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...
jvalencia
 
Posts: 19
Joined: Fri Apr 13, 2018 4:43 pm

Next

Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 14 guests