windows-console

How to execute Windows CLI commands in Ruby?

家住魔仙堡 提交于 2019-11-27 18:42:42
问题 I have a file located in the directory "C:\Documents and Settings\test.exe" but when I write the command `C:\Documents and Settings\test.exe in single qoutes(which I am not able to display in this box), used for executing the commands in Ruby, I am not able to do so and the error that I recieve is No file or Directory found. I have tried replacing "\" with "//" and "\" but nothing seems to work. I have also used system, IO.popen and exec commands but all efforts are in vain. Also exec

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

﹥>﹥吖頭↗ 提交于 2019-11-27 14:03:48
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. 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') ←[31mhello←[0m >>> import colorama >>> colorama.init() >>> cprint('hello', 'red') hello <-- in red color >>> 来源:

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

纵饮孤独 提交于 2019-11-27 14:02:07
问题 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 "

How can I write to the console window for debugging?

孤者浪人 提交于 2019-11-27 11:35:27
问题 Can I display the result of a loop in the console window in a VCL application for debugging purposes? 回答1: 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

Gracefully terminate a Boost Asio based Windows console application

雨燕双飞 提交于 2019-11-27 07:23:24
问题 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? 回答1: Update Just use any IPC method you would "normally" use Write a simple process control utility that uses e.g. named_condition

Displaying Unicode in Powershell

佐手、 提交于 2019-11-27 06:55:22
What I'm trying to achieve is rather straightforward though Powershell is making it almost impossible. I want to display the full path of files, some with Arabic, Chinese, Japanese and Russian characters in their names I always get some undecipherable output, such as the one shown below The output seen in console is being consumed as is by another script. The output contains ? instead of the actual characters. The command executed is (Get-ChildItem -Recurse -Path "D:\test" -Include *unicode* | Get-ChildItem -Recurse).FullName Is there any easy way to launch powershell (via command line or in

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

邮差的信 提交于 2019-11-27 06:02:52
问题 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. 回答1: You'll need to use the *ConsoleInput family of methods (peek, read, etc). These operate on the console's input buffer, which includes keyboard

How to avoid console window with .pyw file containing os.system call?

天涯浪子 提交于 2019-11-27 01:52:43
If I save my code files as .pyw , no console window appears - which is what I want - but if the code includes a call to os.system , I still get a pesky console window. I assume it's caused by the call to os.system . Is there a way to execute other files from within my .pyw script without raising the console window at all? robince You could try using the subprocess module ( subprocess.Popen , subprocess.call or whatever) with the argument shell=True if you want to avoid starting a console window. You should use subprocess.Popen class passing as startupinfo parameter's value instance of

Colored text output in PowerShell console using ANSI / VT100 codes

假装没事ソ 提交于 2019-11-27 01:38:06
问题 I wrote a program which prints a string, which contains ANSI escape sequences to make the text colored. But it doesn't work as expected in the default Windows 10 console, as you can see in the screenshot. The program output appears with the escape sequences as printed characters. If I feed that string to PowerShell via a variable or piping, the output appears as intended (red text). How can I achieve that the program prints colored text without any workarounds? This is my program source

Getting terminal size in c for windows?

泪湿孤枕 提交于 2019-11-27 01:12:34
How to check ymax and xmax in a console window, under Windows, using plain c? There is this piece of code for linux: #include <stdio.h> #include <sys/ioctl.h> int main (void) { struct winsize max; ioctl(0, TIOCGWINSZ , &max); printf ("lines %d\n", max.ws_row); printf ("columns %d\n", max.ws_col); } Now I wonder how can I do the same for windows. I tried winioctl.h but it does not define struct winsize nor any other with a similar name. Any tips? Thanks. PS. In linux you also can find the console size using getenv("LINES"); . Is there a similar variable under windows? PPS. Also, there is always