02-03-2012 12:32 AM
I am working on a project where I am controlling a LabSat 2 GPS generator. The unit came with an already compiled C# program that gets run from the command line. I am using the system exec vi to run the command and this then starts the LabSat 2 transmitting. Other devices are also started and the test runs.
The problem I am having is if the user wants to stop the test at any point, I need to stop the LabSat2 transmitting. The way to do this is to send a Ctrl+C to the already open DOS window. In my sample program to test this, I start the LabSat 2, wait 5 seconds and then try stop it. When I write cmd /c to a new system exec vi, it opens a new DOS window and then closes it.
Is there any way to write the CTRL+C command to a window that is already open, one that was opened ealrier in the program and is still running?
Any help would be greatly appreciated. I am attaching my vi to explain what better what I am trying to do. This vi is only to get the idea working and then I will add it to the rest of my project.
Regards,
Greg
Solved! Go to Solution.
02-03-2012 02:08 AM
Hi Greg,
As a first thought for your question, what i feel is in order to not to display the command window popping up when you write /c to new system exec, change the run minimised option to "true".
02-03-2012 02:13 AM
Thanks for the advice but that doesn't make a difference.
02-03-2012 02:36 AM
Passing the Ctrl+C command to an already opened C# Dos executable is possible using the WIN APIs. You need to get the Window Handle, then use attach console from kernel32.dll. Once you do this, you would need to explore Keyboard Input functions from MSDN, wherein you would get the command to send the Key Combination you are looking for.
Use Call Library Function nodes to call into the WINAPI Dlls.
02-03-2012 03:42 AM
Thanks for the help. I got it working by using user32.dll to get the window to the front and then again using user32.dll i send the required keyboard inputs.
Thanks again
05-02-2012 10:59 AM
Hi,
How do you write into DOS window? Any tip help. My labview version is 10
Thanks,
Ott
05-02-2012 01:00 PM
@Ott wrote:
Hi,
How do you write into DOS window? Any tip help. My labview version is 10
Thanks,
Ott
Please do not create the same question in multiple places. Stick to your original post and have some patience.
01-26-2015 09:28 AM
Hi
I am facing the problem, what you faced regarding command window.
I have to run a java applicaiton on command and should terminate using ctrl+c after few minutes. Can you please share me the details how you achieved this funcationality. Also please share the code if possible.
Rgds
Kris
01-27-2015 12:20 AM
Hi Kris,
I wrote two blog posts a while back that might help. The first link shows how to make the window active and then the second link shows how to simulate keyboard presses which would be applied to the open window.
http://www.labvolution.com/labview-making-a-window-active/
http://www.labvolution.com/labview-simulating-keyboard-events/
There is a link at the bottom of each post where you can download the code.
I hope this help. If you are still stuck I can try look in to it a bit more.
Greg