windows-console

Multiple consoles for a single application C++

妖精的绣舞 提交于 2019-11-28 23:17:23
问题 Is it possible to create two console windows (one being the main) and the secondary being a pop-up like a message box in Windows Forms? I only want the secondary console window to hold IDs (that will be hard coded into the application) So the user does not have to keep returning to the main menu to check available IDs If so how would you go about it? Many Thanks 回答1: Yes, you can do it. The solution is actually very simple - our process can start a new helper child-process, so the helper

What to do with “The input line is too long” error message?

一个人想着一个人 提交于 2019-11-28 21:38:58
I am trying to use os.system() to call another program that takes an input and an output file. The command I use is ~250 characters due to the long folder names. When I try to call the command, I'm getting an error: The input line is too long . I'm guessing there's a 255 character limit (its built using a C system call, but I couldn't find the limitations on that either). I tried changing the directory with os.chdir() to reduce the folder trail lengths, but when I try using os.system() with "..\folder\filename" it apparently can't handle relative path names. Is there any way to get around this

How can I write to the console window for debugging?

大憨熊 提交于 2019-11-28 18:41:52
Can I display the result of a loop in the console window in a VCL application for debugging purposes? In Windows, the simplest way to output debug information is to use OutputDebugString() and then use an application able to receive that output. The event viewer in the Delphi IDE itself is able to receive that input, or you can use the DebugView application from SysInternals to get output on a system that hasn't the IDE installed. AFAIK, GExperts has a similar tool too. That's because a GUI application has not by default a console where to write output, otherwise you have to create one (see

Gracefully terminate a Boost Asio based Windows console application

删除回忆录丶 提交于 2019-11-28 12:45:39
I am working on a boost.asio based HTTP server. It is supposed to be stopped externally. We use asio signal handling, and it works well for ctrl-c, but does not handle WM_CLOSE, so there is no straightforward way to gracefully close the application externally, e.g. via taskkill. Terminating the process forcibly is not an option. Is there a known approach to this? Update Just use any IPC method you would "normally" use Write a simple process control utility that uses e.g. named_condition to signal your asio process to shutdown. Note that named_codition is somewhat equivalent to a Win32 Named

How can I get the mouse position in a console program?

拜拜、爱过 提交于 2019-11-28 11:18:14
How can I get the mouse click position in C++ in a Windows console program? (A variable that returns the position of the mouse when clicked) I want to draw a menu with simple text commands, so when someone clicks, the game will register it and know the position. I know how to do everything I need to do except get the mouse position when clicked. You'll need to use the *ConsoleInput family of methods (peek, read, etc). These operate on the console's input buffer, which includes keyboard and mouse events . The general strategy is: wait on the console's input buffer handle ( ReadConsoleInput )

Is there a limit on the output of Console Window?

六月ゝ 毕业季﹏ 提交于 2019-11-28 08:57:20
问题 Code: This program checks if the 2 numbers entered and their sum are divisible by the numbers 2 - 9, and displays the remaining divisible numbers (excluding the one being reviewed). static void Main(string[] args) { for (int i = 2; i < 10; i++) { Challenge(2, 6, i); } Console.ReadLine(); } static void Challenge(int num1, int num2, int Divisor) { int sum = num1 + num2; bool SumDivisible = sum % Divisor == 0; bool num1Divisible = num1 % Divisor == 0; bool num2Divisible = num2 % Divisor == 0;

Console App Terminating Before async Call Completion

你离开我真会死。 提交于 2019-11-28 06:13:48
I'm currently writing a C# console app that generates a number of URLs that point to different images on a web site and then downloads as byte streams using WebClient.DownloadDataAsync() . My issue is that once the first asynchronous call is made, the console app considers the program to be completed and terminates before the asynchronous call can return. By using a Console.Read() I can force the console to stay open but this doesn't seem like very good design. Furthermore if the user hits enter during the process (while the console is waiting for input) the program will terminate. Is there a

HtmlAgilityPack & Windows 8 Metro Apps

我们两清 提交于 2019-11-28 02:03:55
I'm trying to get HtmlAgilityPack to work with Windows 8 Metro Apps (Windows Store Apps). I've successfully written out all the code I need in a Windows Console App (C#) and it works perfectly for parsing the HTML I need and returning me the required string I need. // Create a new HtmlDocument and load the incoming string HtmlDocument menu = new HtmlDocument(); menu.OptionUseIdAttribute = true; menu.LoadHtml(response); HtmlNode nameToRemove = menu.DocumentNode.SelectSingleNode("//*[@id=\"maincontent_0_contentplaceholder_0_lblHall\"]"); My problem is with the DocumentNode.SelectSingleNode call.

Restore default working dir if bat file is terminated abruptly

为君一笑 提交于 2019-11-28 00:56:30
I have a scenario where during execution of a batch file, it navigates to a different folder (say to "../asdf"); and at the end of execution it will set the current working dir as the same folder from where the user called the .bat file. But if the user terminates the batch processing before it is complete, the cmd show the current working dir (say "../asdf"). But in my case, I need to restore the working dir to the default/predefined one. Is it possible? Batch file is written by me, so I can modify it. CMD is opened through a desktop shortcut to CMD, which I have control of; so properties

How to use the new support for ANSI escape sequences in the Windows 10 console?

人走茶凉 提交于 2019-11-27 22:10:21
The latest Windows 10 updates include support for ANSI escape sequences in conhost.exe. I have been able to confirm that the escape sequences are properly picked up in cmd.exe, so I have the necessary updates. In particular, I tried typing in prompt $e[?25l , which hides the cursor, and then prompt $e[?25h , which again shows the cursor. However, if I start a Python interpreter, and then do the following: >>> import sys >>> sys.stdout.write("\033[?25l") Well, the cursor isn't hidden. How can I set things up the right way so that the console is able to get escape sequences from Python? The