console-application

How to make a batch file that send application an input char

一世执手 提交于 2019-12-01 06:53:11
I'm writing a batch file that launch an application. app.exe After the application is launched, I'm getting a list of options in the console, and the program waits for input, for example: a: start session b: end session c: end How do I make the batch type a ? David R Tribble Other than using echo as @npclaudiu suggested, you could also write the expected input to a text file and then have the app read the file: app.exe <input.txt This works if the app expects more than one line of input. First, make sure if the application supports command line arguments. For example, at your command prompt,

Why does the Node.js scripts console close instantly in Windows 8?

微笑、不失礼 提交于 2019-12-01 06:27:42
I've tried nearly every example for scripts I can find. Every sample opens the terminal for a split second. Even this closes as soon as input is entered. Is this normal? var rl = require('readline'); var prompts = rl.createInterface(process.stdin, process.stdout); prompts.question("How many servings of fruits and vegetables do you eat each day? ", function (servings) { var message = ''; if (servings < 5) { message = "Since you're only eating " + servings + " right now, you might want to start eating " + (5 - servings) + " more."; } else { message = "Excellent, your diet is on the right track!"

Modifying text in the terminal

拈花ヽ惹草 提交于 2019-12-01 06:18:41
问题 Is it possible to modify text I printed to the terminal without clearing the screen? For instance, if I'm showing progress of something in percentage, can I modify that percentage without having to clear the screen and printing again? I'm looking for a cross-platform way, if there is one. Talking C++. thanks 回答1: There are a number of ways to do this, and depending on how much effort you want to put into it, you can do a lot of cool things with ascii text in a terminal window. Advanced:

IS it possible to have savefiledialog () in windows console applications

☆樱花仙子☆ 提交于 2019-12-01 06:17:34
问题 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Diagnostics { class Program { static void Main(string[] args) { string filename = null; using (SaveFileDialog sFile = new SaveFileDialog()) { sFile.Filter = "Text (Tab delimited)(*.txt)|*.txt|CSV (Comma separated)(*.csv)|*.csv"; if (sFile.ShowDialog() == DialogResult.OK) { filename = sFile.FileName; WriteRegKey(diagnostic, filename); } } } } } I am getting an error: The type or namespace name

Set C# console application to Unicode output

懵懂的女人 提交于 2019-12-01 06:07:58
I have a C# console application, and I was trying to do some ASCII art within it. However, some of the characters I wanted to use are Unicode. So, I was searching the internet/SO and couldn't find a consolidated answer on how to set the console to be Unicode in a C# console application. TDLR: How do I set the console in a C# console application to be Unicode? Edit: I did find this post after searching for something not related to this question. Michael Yanni It turns out that there are multiple things you need to set up in order to make the console display Unicode characters. Set the console

On Windows, how does console window ownership work?

故事扮演 提交于 2019-12-01 06:01:07
When a console application is started from another console application, how does console ownership work? I see four possibilities: The second application inherits the console from the first application for its lifetime, with the console returning to the original owner on exit. Each application has its own console. Windows then somehow merges the content of the two into what the "console" visible to the user The second application get a handle to the console that belongs to the first application. The console is placed into shared memory and both applications have equal "ownership" It's quite

How to make a batch file that send application an input char

早过忘川 提交于 2019-12-01 05:29:18
问题 I'm writing a batch file that launch an application. app.exe After the application is launched, I'm getting a list of options in the console, and the program waits for input, for example: a: start session b: end session c: end How do I make the batch type a ? 回答1: Other than using echo as @npclaudiu suggested, you could also write the expected input to a text file and then have the app read the file: app.exe <input.txt This works if the app expects more than one line of input. 回答2: First,

Run a console application from a windows Form

白昼怎懂夜的黑 提交于 2019-12-01 05:12:16
问题 I have a windows console app (that accepts parameters) and runs a process. I was wondering if there was any way to run this app from within a windows form button click event. I would like to pass an argument to it as well. Thanks 回答1: Just use System.Diagnostics.Process.Start with the path to the console application, and the parameters as the second argument. 回答2: Assuming you have a form with a multiline textbox called txtOutput..... private void RunCommandLine(string commandText) { try {

Global variable in a static method

ぃ、小莉子 提交于 2019-12-01 04:29:14
This seems basic but Im finding this quite trivial. Simply how would you recommend setting a global variable with a static class (i.e. console-application)? To give you a little more background the main method is calling some custom eventhandlers that I hope to get / set the variables. Any ideas or suggestions you have is appreciated. Simplest way is public static Object MyGlobalVariable; which creates a public static field. A little better is: public static Object MyGlobalVariable { get; set; } Which creates a public static property. There are no global variables in C#. A variable is always

How to use await in a parallel foreach?

流过昼夜 提交于 2019-12-01 04:23:14
So I sepnt the better part of the night trying to figure this out. I was fortunate to get introduced to the parallel.foreach yesterday and it works like I want it to do except from one detail. I have the following: Parallel.ForEach(data, (d) => { try { MyMethod(d, measurements); } catch (Exception e) { // logg } }); Within the method "MyMethod" I have alot of logic that gets done and most of it is fine but I make api calls where I fetch data and I use async task for this to be able to use "await" in order for the code to wait untill that specific part gets executed and then move on: private