I just finished writing a program, (download here if you're interested) Basically, it is like an etch-a-sketch. here's a screenshot of version 1:
Version 2 is more like a pixelated painting program. Here's a screenshot: As you can see, v2 supports 16 different colors.
Anyway, I want the users to be able to "save" their creations. I know that I can highlight everything, and copy it into a text file, but this does not get the colors, and there isn't a clean way to do this (that I know of).
Is there a command line tool that I can download to save screen output as an image? Or am I screwed?
By the way, This is just a batch file, compiled with This program. It only works compiled, because the compiler features advanced commands, the kind that allow me to have multiple colors in one window. You can check out the source code here. All lines starting with REM are the "advanced commands".
:edit
I was originally just going to go with a method that saves all of the text, but when I add colors, it looks something like this. Here is what it should look like:
You can use this commandline tool (I made it in AutoIt):
Capture.exe
Use :
capture.exe outputFile.jpg (png,bmp)
It will capture the entire screen.
EDIT :
You can use THIS new one :
Use :
Capture.exe "Title_of_the_Windows"
So in your bat, give a title to your CMD windows, using :
Title capture
and then display your colored text, and just make a :
Capture.exe "Capture"
This will create Output.jpg.
you can do this without external tools ,but you'll need .net framework (installed on windows from vista and above by default) and screenCapture.bat
call screenCapture screen.png png n
Related
I'm trying to make a login batch file that starts a few services but in a way that the user knows they are being started. So I thought I'd use a batch script for that.
The script is working fine, but I wanted to embellish it a bit more using the logo in ASCII and use colors. Everything is working fine on my development PC (Windows 10 64-bit), but on the user machines (Windows 7 64-bit) the colors are not being shown.
I'm using:
echo <ESC>[93m Logging in
But when I run it, I displays:
←[93m Logging in
So it's not treating the ESC properly.
The issue has to be PC based because it's working on another machine, but I don't know how to solve this.
Only console of Windows 10 supports ESC sequences as documented on MSDN page Console Virtual Terminal Sequences. Console host of previous Windows versions don't support ANSI ESC sequences.
There is the command COLOR to define text color and background color.
Open a command prompt window and run color /? for help on this command.
Hundreds of batch file examples on how to use COLOR can be found on Stack Overflow for example with the search term [batch-file] color.
As mented befoer me, windows prior 10 does not support escape sequences. You could try ANSICON
the old ANSI.SYS, which was loaded at boot time would interpret color commands
such as [esc][1;33;40m (where [esc] was a small arrow) as the foreground and
background colors for text in the DOS prompt window, or outside of windows in
a DOS session. (Worked in Windows 3.1x, Win 95, Win 98 1st and 2nd, Win ME and
perhaps even 32 bit Win XP.)
However,after the introduction of 64-bit systems, ANSI.SYS no longer works as before.
The command "color" in a Windows 7 cmd.exe window colors the ENTIRE window text, not
just the part you want to color. I understand some of this has been alleviated in
Win 10 cmd.exe, but except for that...
There may be a possible solution:
called "CoColor" by Horst Schaeffer
Freeware © Horst Schaeffer -- Contact: horst.schaeffer#gmail.com
http://www.horstmuc.de/wcon.htm
Here is what he says about it:
CoColor 2.1 Change console output color Download 32 bit (6Kb)
Download 64 bit (7Kb)
CoColor changes the console color for the succeeding console output, not for the entire window, like the built-in COLOR command. CoColor uses the same color codes as COLOR.
CoColor also accepts a sequence of color codes and text strings (each in double quote marks), making it a colorful ECHO replacement. Non-ASCII characters will be handled the same way as by ECHO.
Demo.CMD is included.
(NOTE: After running Demo.cmd you will need to run the command color to return
to the default colors of the screen. He did not include that in his script.)
After scanning the files with Avast Antivirus, SuperAntiSpyware and Malwarebytes,
I ran the CoColor 64-bit version on Win 7 Pro 64-bit and it seems to work well.
I wrote a lot of batches back in the old days with color bars for the lines of
text. They did NOT change the color of the entire screen as does the "color"
command in cmd.exe! COMMAND.COM understood color commands with ANSI.SYS loaded
at boot time in the CONFIG.SYS. This is the closest thing I've seen yet to that
original functionality. Hope this helps.
I want to create a batch file, but I can't find a way to select the coding language. If it is not there, is there another program I can use to code something for a school project in batch?
Go to Start>Programs>Accessories>Command Prompt and right-click; Send to desktop.
This will create a desktop "shortcut".
Right-click on the shortcut to set properties like text colour, size and font.
This will open what is commonly referred to as a "Dos session."
you can exit from that screen (It isn't DOS - it emulates DOS) by typing
QUIT
(and every command ends with the enter key (never shown)
Then just use a text-editor (Notepad at a pinch, I prefer Editplus to create the programs.
Just google "batch file programming tutorial" or something, I promise you will find something interesting. Go through this, for example: http://www.dreamincode.net/forums/topic/55203-batch-tutorial-part-1/ to get a basic understanding of batch and programming (although I wouldn't call batch programming; more likely to be called a scripting language).
(By the way, I find Notepad++ very good, but you don't need a special editor, as any text editor, for example Notepad.exe works fine, pre-installed with Windows.)
I'm new to using batch but I know basic commands. I'm trying to show one message (via echo or something like that) in one color. And another message in another color. (the color command colors all the text in the window instead of letting me choose what to color)
I want to do this without external software (although I am using DOSBox instead of cmd - if it matters at all), please explain your code so I can understand and learn.
Thanks.
http://www.dostips.com/forum/viewtopic.php?f=3&t=4453
Here's a ready for use color function
I have an executable that accepts typed user input on three seperate lines on the GUI. The executable also has a button called "create file" that will perform a file creation based on the typed data. My question is how can I automate passing the three typed values into the executable and then execute the "create file" button all from a batch file? I do not have access to the source code so I cannot make modifications there to achieve this.
(Im not able to write comments yet, so I have to use an "answer")
I agree Cebence, as far as I know you need some kind of macro player. Best free I know of is autohotkey (just google for it). It needs a bit reading in at first but is pretty easy to use and very versatile.
Well, this is not really a batch file solution - I don't think one exists. But you could use a tool like Spy++ to find the IDs of the relevant dialog controls and then write a program to:
Launch the executable
Retrieve the main window handle
Send the appropriate window messages
There is probably software out there that can do this. Maybe there's something that you can batch which will just take the process name or ID and pass a single message to it.
If the GUI application doesn't support command-line arguments BAT file will not be of much help here.
What you actually need is some kind of "GUI macro player" application that will execute a script, i.e. macro like this one:
Switch focus to running application named "XYZ"
Find the input box named "text1" and type in "${param1}"
Find the input box named "text2" and type in "${param2}"
Find the input box named "text3" and type in "${param3}"
Find the button named "button" and click it.
I don't know if there are (free) applications that can do this now, but there was a free application called "Act!" or something like it (its icon was a yellow Mickey Mouse glove with a finger pushing a button). It was actually a ZIP file containing a running Windows executable and Delphi application source code, but I can't find it now on PC Magazine's website.
Hope this helps.
I have been writing my code in IDE,I just read that there also existed a Command Line Development Environment in which the code is written in DOS.I googled but found no results on how to use the command line development environment.My OS is Windows XP.I would be very thankful for your help me write the hello world program in DOS and also explain how to run it.
You simply use whatever text editor you like to create the C sourse file(s) then invoke the compiler command line(s) to compile and link the program (typically, an IDE is doing exactly that, but in a behind-the-scene manner). How the command line is invoked depends on the exact toolchain you're using.
You might also need to set up an environment for you particular compiler toolchain (the right paths and various other env variables might need set up).
For Visual C++ the environment might be set up using a batch file installed by Visual Studio:
vcvarsall x86
Invoking the compiler could be as simple as:
cl helloworld.c
or for C++ (for some reason it issues a non-fatal warning if you don't give it an option configuring details about how it should implement exceptions):
cl /EHsc helloworld.cpp
The particulars are very dependent on the compiler you're using - you should read the docs for that compiler.
Also, the options you use depend on your particular situation and needs. Scripts/batch files and/or makefile can help you manage the complexity of the options you might need to use.
DOS is not dead.... yet!
fahad
There are a number of methods by which you can enter code in DOS (see EDIT further on down).
(1) You can send keystrokes directly to a file
You do this by redirecting output to CON (the console) to a file. The only oddity of this method is that you end the 'session' by entering a CTRL-Z when you are finished.
It's basic, but this is how it goes.
Firstly, suppose you want to display "Hello World" on the screen, a simple batch file containing the following two lines is all that is required:
#echo off
echo Hello World
The '#echo off' is commonly found at the start of all batch files. It simply instructs the command interpretter NOT to display each command as it is being executed (or parsed).
One more thing before we start. Throughout this answer, I will assume your program is named 'helloworld.bat'.
Enter the following lines one after the other pressing the ENTER key at the end of each line:
copy con helloworld.bat
#echo off
echo Hello World
^Z
The '^Z' is displayed when you press the CTRL-Z key combination (don't forget to press the ENTER key as well).
When you press the ENTER key after CTRL-Z, DOS displays the familiar '1 File(s) copied' messege.
You can now execute the batch file program by simply entering the program's name like this:
helloworld
And DOS will display the following:
Hello World
It can't get any more basic than that.
(2) You can use DOS' EDIT program
This is a DOS based IDE retained from around the mid-90's. Simply enter the following command:
edit
And EDIT will open in the same DOS window. When you close EDIT, you are returned back to DOS again.
EDIT also works with your mouse.
Once EDIT opens, enter the following two lines of code:
#echo off
echo Hello World
Then, click on [File], [Save], type: 'helloworld.bat' in the "File Name" input field, use your mouse to change directories in the "Directories:" pane if you want to, then click [OK]. To return to DOS, click [File], [Exit].
EDIT version 4.5 (I think) was context-sensitive and displayed code using different colours to seperate key word, different data type, symbols etc.
(3) Use Windows' built-in Notepad
This is simple. At the command prompt, enter the following command:
notepad
And Notepad will fire up. It's a simple text editor and does the job when entering small programs.
(4) Use Notepad++. It's FREE!!
Notepad++ is the programmer's choice. It's free, full of useful features and customisable. Find it on the net by searching for "notepad++".
From your comment, "Just some knowledge so I can say that I know one way to do programming without IDE" I would say learn to write simple batch files. They can be run from Explorer but they exist as a holdover from the DOS days.
Start a command prompt window (Start->Run->'cmd'), this will open a window and show a prompt, most likely "c:\" or some other path.
Type the following command (followed by )
echo "Hello World"
You should see:
"Hello World"
c:\
Now, using whatever editor you'd like, create a text file with that command as the only line. Name the file "hello.bat". When you are at the command prompt you can execute the batch file like so:
c:\hello.bat
"Hello World"
c:\
You have now programmed using the DOS command line. For more commands and such, start with the help system.
c:\help
Which will display all the available commands for your batch file.
Microsoft has an online reference here.
DOS is dead for all practical purposes. Under Windows your options boil down to the following:
Use an IDE. Visual Studio is one example, Qt another. You can write programs for the commandline with an IDE.
Use a proper text editor, build tool and other helper tools. You might use gvim for editing code, make for building your project and git for version control. You might as well use the GNU coreutils for other helpers, or maybe even the entire cygwin package.
Bro, use gcc compiler for which write ur code in any text editor then compile ur code in windows shell or u can say command line environment.
Look!
Prompt:/> gcc source_file_name.c
This command compiles ur code,
If there is any error, u will get dispalyed with line numbers,
now, every program creates its exe file by the name a.exe by default.
To, get the output of ur program,
Prompt:/> a.exe
O/P
Hello World!
To change the name of the exe file there is also a command..