ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulating Keyboard Std In/Out in cmd

Solved!
Go to solution

Hello All,

 

I have a .bat file which I run using System Exec VI.

After starting, the user will be required to hit 1 twice so that the programme can be executed. I want to avoid hitting the keyboard, so I can send this through labview so my programme runs fully Automated without any Input from the user.

I tried this without success maybe someone has an idea how I can implement this. Also I will like to read the result from the cmd window after the execution.

 

thanks in advance for your suggestions

0 Kudos
Message 1 of 8
(6,892 Views)

So why not prompt for user input within Labview before starting the CMD?  That way, the CMD prompt is only used for running the compile routine. 

aputman
0 Kudos
Message 2 of 8
(6,867 Views)

After rereading your question, I understand what you are saying.  I was assuming you have source code for the routine and I think that was a wrong assumption.  You want to start the routine, simulate two keypresses with Labview and let it run. 

 

I think you will need to dip into Windows dlls or .NET to accomplish that.  I posted a link in another post earlier today about calling a CMD prompt from .NET (which I think would be possible...not having done it myself).  This .NET function would potentially return a window handle that you could then use to send some simulated keyboard input.  The .NET constructor is System.Diagnostic.Process.  Give it a try and see what happens. 

 

http://stackoverflow.com/questions/691716/running-cmd-commands-via-net

aputman
0 Kudos
Message 3 of 8
(6,857 Views)

thanks aputman, I will try it.

0 Kudos
Message 4 of 8
(6,852 Views)

You shouldn't have to simulate anything.  System Exec has a standard input for just such an occasion.  Call your bat file in the command line and send the input in through the standard input.  Or maybe I misunderstood you?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 8
(6,837 Views)

Hello Billko,

You did not misunderstand me. I did that "sending 1 through the Std Input" but nothing happens.

Maybe I am missing something.

 

Thanks

0 Kudos
Message 6 of 8
(6,803 Views)

@Frank_view wrote:

Hello Billko,

You did not misunderstand me. I did that "sending 1 through the Std Input" but nothing happens.

Maybe I am missing something.

 

Thanks


Ugh, I didn't the /k switch.  I'm not sure it works with that switch.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(6,758 Views)
Solution
Accepted by topic author Frank_view

Hello all,

thank you for your responses and contributions. I have a solution which I can now use. I saw a VI made by user "Michael_W." on "Programmatically Simulate Key Strokes in LabVIEW"

I have used one of the VI's to simulate my keyboard input when needed and it works as required.

Attached is a rough and quick implementation with the VI.

 

Thanks

Message 8 of 8
(6,730 Views)