windows-console

Changing the focus back to the console window

对着背影说爱祢 提交于 2019-12-23 15:38:33
问题 My knowledge of Windows programming is close to zero. But now I have made a Forth program running from the console in Windows which opening a primitive window for graphics. The problem is that I want to control the program by pressing keys, but when the program starts there is no focus on the console window, just on the graphic window. How do I change back focus? I guess I have to use some WINAPI, but which? 来源: https://stackoverflow.com/questions/41272078/changing-the-focus-back-to-the

How to execue PHP scripts in the background using EXEC() and CMD

蓝咒 提交于 2019-12-23 03:20:18
问题 I can't use the $com = new Com('WScript.shell'); way, it's causing problems on my system. Probably I need to upgrade my PHP because it's very old (5.2), but I suppose what I'm trying to do is not version dependent. I'm running PHP on Windows 2008 64-bit. Where I can run a command prefixed with start to run the command on a separate console. start php myscript.php If this is executed from the command line, it starts a new console for the script. I need to do the same from PHP using exec only .

How do I write special characters (0x80..0x9F) to the Windows console?

青春壹個敷衍的年華 提交于 2019-12-22 06:37:12
问题 I would like to have this code: System.Console.Out.WriteLine ("œil"); display œil instead of oil as it does in my test program. The Console.OutputEncoding is set by default to Western European (DOS) ( CodePage set to 850 and WindowsCodePage set to 1252) on my system. The character set contains the special OE and oe diphtongs (as can be seen on the Wikipedia article on Windows-1252) but somehow, I suspect that the characters not found in the ISO-8859-1 set get discarded/replaced. Characters

How can I get Mocha's Unicode output to display properly in a Windows console?

天大地大妈咪最大 提交于 2019-12-21 04:06:59
问题 When I run Mocha, it tries to show a check mark or an X for a passing or a failing test run, respectively. I've seen great-looking screenshots of Mocha's output. But those screenshots were all taken on Macs or Linux. In a console window on Windows, these characters both show up as a nondescript empty-box character, the classic "huh?" glyph: If I highlight the text in the console window and copy it to the clipboard, I do see actual Unicode characters; I can paste the fancy characters into a

Preventing MSYS 'bash' from killing processes that trap ^C

懵懂的女人 提交于 2019-12-20 09:28:08
问题 I have a console-mode Windows application (ported from Unix) that was originally designed to do a clean exit when it received ^C (Unix SIGINT ). A clean exit in this case involves waiting, potentially quite a long time, for remote network connections to close down. (I know this is not the normal behavior of ^C but I am not in a position to change it.) The program is single-threaded. I can trap ^C with either signal(SIGINT) (as under Unix) or with SetConsoleCtrlHandler. Either works correctly

C# library for more ConsoleColors? [duplicate]

元气小坏坏 提交于 2019-12-20 01:12:38
问题 This question already has answers here : redefining Console colour palette in c# (1 answer) Custom text color in C# console application? (10 answers) Closed 6 years ago . I have been writing console apps for a while and noticed that the consoles (such as cmd.exe) support RGB colors but the 'Console' class for .NET doesn't. Does anyone know of a library that would allow RGB colors for a console app in C#? 回答1: I have found a solution but it is not worth the time and effort, this should be

How to read very long input from console in C#?

谁说我不能喝 提交于 2019-12-19 19:57:17
问题 I need to load veeeery long line from console in C#, up to 65000 chars. Console.ReadLine itself has a limit of 254 chars(+2 for escape sequences), but I can use this: static string ReadLine() { Stream inputStream = Console.OpenStandardInput(READLINE_BUFFER_SIZE); byte[] bytes = new byte[READLINE_BUFFER_SIZE]; int outputLength = inputStream.Read(bytes, 0, READLINE_BUFFER_SIZE); Console.WriteLine(outputLength); char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputLength); return new string

Hiding the console window after reading input

孤者浪人 提交于 2019-12-19 09:58:46
问题 I have a script that has a GUI, which takes user data and stores it into a text file. It runs another script (an .exe), which waits for user input and then does some work. What I want is for the latter script to hide its console window after reading input from the user, but to continue working in the background. I tried to run that script with subprocess.call('lastscript.exe', shell=True) or subprocess.Popen('lastscript.exe', shell=True) . This doesn't work. I have to take input from the user

Windows console application - signal for closing event

♀尐吖头ヾ 提交于 2019-12-18 06:56:29
问题 In windows console application, one can catch pressing ctrl+c by using: #include <stdio.h> #include <signal.h> void SigInt_Handler(int n_signal) { printf("interrupted\n"); } int main(int n_arg_num, const char **p_arg_list) { signal(SIGINT, &SigInt_Handler); getchar(); // wait for user intervention } This works well, except it does not work at all if the user presses the cross × that closes the console window. Is there any signal for that? The reason I need this is I have this CUDA application

Why does termcolor output control characters instead of colored text in the Windows console?

孤人 提交于 2019-12-17 10:53:37
问题 I just installed termcolor for Python 2.7 on Windows. When I try to print colored text, I get the color codes instead. from termcolor import colored print colored('Text text text', 'red') Here is the result: I obtain the same results on Far Manager and when I tried to run the script as a standalone application. 回答1: To make the ANSI colors used in termcolor work with the windows terminal, you'll need to also import/init colorama; >>> from termcolor import * >>> cprint('hello', 'red') ←