Command prompt doesn't refresh on its own [duplicate] - windows

This question already has answers here:
Command prompt gets stuck and continues on enter key press
(3 answers)
Closed 8 months ago.
I have a bat file which invokes a program with bunch of arguments.
start program.exe arg1 2 3
Now program.exe takes a long time to execute, (about 2-4 hours).
When the program is done running, it usually prints the return code and execution times in console. But sometimes I have to press the return key in the console window and then I see the program output.
No idea why is that?

The solution I found from this worked for me. Which is,
Open cmd.exe and click on the icon in the top left corner to get the cmd context menu.
Choose Properties at the bottom of the context menu, and on the dialog select the first tab: Options.
Uncheck the QuickEdit Mode.

Related

Does highlighting text in a command prompt window stop script execution or just prevent output? [duplicate]

This question already has answers here:
How and why does QuickEdit mode in Command Prompt freeze applications?
(2 answers)
Closed 4 years ago.
If you have ever tried highlighting text in a command prompt window while a script is running that is outputting text, you'll notice that it no longer outputs text.
My question is if the highlighting inside a cmd window simply prevents it from outputting text, but still allows the script to run, or if it halts the execution of the script while highlighted?
Regardless of the answer, it would also be nice to know why it does this? Both the reason and purpose would be great.
Thanks
This is done to allow you to make the selection. Otherwise, new output could scroll everything and you would end up not selecting what you wanted.
Only output is suspended. The program will continue executing, however if it uses unbuffered IO, or the buffer it uses is full, it will block on a write call until the selection is done.

Change the previous output in a terminal when a resize occurs

How can I execute a previous command in the terminal when a resize of terminal occurs
For example, when I execute the command ls in terminal what I get is
when I do a resize what I get is
Output of ls in a short window
but when I resize the window to large the previous output of the command does not change and what it looks like is The preview of previous output when I resize window
but I want the terminal to be refreshed itself on resize of the window.
My desired Output
In short, I want a bash script to execute every previous command before or a selected command as a web-browser does.
I had seen the question already before when I asked this question but that question won't provide me a solution because I want my previous command to be executed but not any functions or any other after commands

How can I get quickfix to open results in the previously focused window?

I wrote the following command to search Vim's help files:
command! -n=1 -complete=help SearchHelp \
help | execute "grep! -i <args> $VIMRUNTIME/doc/ -r" | botright copen
Now, for example, when I have forgotten the key to increment the number under the cursor, I can do:
:SearchHelp increment
to search through the help files. (The answer turned out to be <Ctrl-A>.)
The problem is ... I have a few windows open, and I want quickfix to leave them alone. When I hit <Enter> in the quickfix list, I want it to open the result in that help window which I split open at the beginning of the command.
But it doesn't do this. It seems to prefer to always open the result in the bottom-most of all my editing windows, regardless of which window I was focused on, and with complete disinterest for the help window I opened. Obviously this moves away from whatever file I happened to be editing in that window (yes I have :set hidden), requiring an arbitrary number of <Ctrl-O> keys to get back to the file when I have finished browsing the help files.
So how can I get quickfix to open in the previously focused window (ideally that help window that was split open)?
(Incidentally, I sometimes use a patched version of Yegappan Lakshmanan's old grep.vim plugin, and somehow this does open :cope results in the window that had focus before I ran :Grep. I am not sure what's different in the two situations.)
The behavior (among others like :sbuffer) is controlled by the 'switchbuf' option. With a value of useopen, you can make it re-use a window if it already displays that help page. If you need more control than what is offered by that option, you do need to use a custom command / mapping.
So far what I have come up with is to replace that help command with:
99wincmd j | wincmd s
This splits whatever window happens to be at the bottom of the screen, so that when the quickfix clobbers the bottom one, I still have a window that keeps the file visible.
This solution is workable, but not quite as neat as my preferred result, which is to open results in the help window which was split just above the window I was focused on when I ran the command.

Automatically step by step debugging in Visual Studio?

I was getting tired of hitting the F10 every step to debug the programs. Are there any program can automate the visual studio to run each debugging step in a consistent frequency? say, 3 seconds for each step?
Regards,
Sam
You can easily do that with a simple script in Autohotkey.
Download it from here: http://www.autohotkey.com/
Install Autohotkey.
Run it.
Find the green "H" icon in the task bar (bottom right).
Right click the icon and select Edit script.
And copy paste this script below.
^!y::
InputBox, input1, How many F10 strokes you want?, , , 250, 100
InputBox, input2, How many seconds between each F10 stroke?, , , 250, 100
if ErrorLevel <> 0
{
MsgBox, CANCEL was pressed.
}
else
{
loop, %input1%
{
Sleep, (input2 * 1000)
Send {F10}
}
MsgBox, "Your F10 script has Ended"
}
return
Then reload (again by right clicking the green "H" icon in task bar).
Press Control+Alt+y to try out the above script.
Sitting there repeatedly hitting F10 can be annoying, but you probably just need to make more use of the inbuilt debugging features.
set a breakpoint at a targetted location and hit F5 to run the program, it will stop when it hits the breakpoint
use F11 to step in to a function
use Shift-F11 to step out of a function
use the breakpoints window (Debug->Windows->Breakpoints) to get a complete list of all the bp's and you can easily enable/disable any of them (or set any of their other options)
use the Exceptions window (Debug->Exceptions) to select exceptions that you want to break on when they are first thrown
familiarize yourself with the options available to breakpoints (right-click on the bp itself to get these)
hit count: specify how many times code should go past the breakpoint before it stops
condition: super useful (i use it all the time), you can use almost any expression in there, including checking the value of inscope variables
when hit: you can run a macro when the breakpoint is hit
filter: to restrict which running thread can break on that breakpoint

Keyboard shortcut to paste clipboard content into command prompt window (Win XP) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)?
The typical Shift+Insert does not seem to work here.
Yes.. but awkward. Link
alt + Space, e, k <-- for copy and
alt + Space, e, p <-- for paste.
I personally use a little AutoHotkey script to remap certain keyboard functions, for the console window (CMD) I use:
; Redefine only when the active window is a console window
#IfWinActive ahk_class ConsoleWindowClass
; Close Command Window with Ctrl+w
$^w::
WinGetTitle sTitle
If (InStr(sTitle, "-")=0) {
Send EXIT{Enter}
} else {
Send ^w
}
return
; Ctrl+up / Down to scroll command window back and forward
^Up::
Send {WheelUp}
return
^Down::
Send {WheelDown}
return
; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !{Space}ep
return
#IfWinActive
Not really programming related, but I found this on Google, there is not a direct keyboard shortcut, but makes it a little quicker.
To enable or disable QuickEdit mode:
Open the MS-DOS program, or the command prompt.
Right-click the title bar and press Properties.
Select the Options tab.
Check or un-check the QuickEdit Mode box.
Press OK.
In the Apply Properties To Shortcut dialog, select the Apply properties to current window only if you wish to change the QuickEdit setting for this session of this window only, or select Modify shortcut that started this window to change the QuickEdit setting for all future invocations of the command prompt, or MS-DOS program.
To Copy text when QuickEdit is enabled:
Click and drag the mouse pointer over the text you want.
Press Enter (or right-click anywhere in the window) to copy the text to the clipboard.
To Paste text when QuickEdit is enabled:
Right-click anywhere in the window.
To Copy text when QuickEdit is disabled:
Right-click the title bar, press Edit on the menu, and press Mark.
Drag the mouse over the text you want to copy.
Press Enter (or right-click anywhere in the window) to copy the text to the clipboard.
To Paste text when QuickEdit is disabled:
Right-click the title bar, press Edit on the menu, and press Paste.
Thanks Pablo, just what I was looking for! However, if I can take the liberty of improving your script slightly, I suggest replacing your ^V macro with the following:
; Use backslash instead of backtick (yes, I am a C++ programmer).
#EscapeChar \
; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return
The advantage of using SendInput is that
it doesn't rely on the command prompt system menu having an "Alt+Space E P" menu item to do the pasting (works for English and Spanish, but not for all languages).
it avoids that nasty flicker you get as the menu is created and destroyed.
Note, it's important to include the "{Raw}" in the SendInput command, in case the clipboard happens to contain "!", "+", "^" or "#".
Note, it uses StringReplace to remove excess Windows carriage return characters. Thanks hugov for that suggestion!
There is also a great open source tool called clink, which extends cmd by many features. One of them is being able to use ctrl+v to insert text.
On Windows 10, you can enable Ctrl + C and Ctrl + V to work in the command prompt:
Here's a free tool that will do it on Windows. I prefer it to a script as it's easy to set up. It runs as a fast native app, works on XP and up, has configuration settings that allow to remap copy/paste/selection keys for command windows:
Plus I know the developers.
simplest method is just the copy the text that you want to paste it in cmd and open cmd goto "properties"---> "option" tab----> check the (give tick mark) "quickEdit mode" and click "ok" .....now you can paste any text from clipboard by doing right click from ur mouse.
Thank you..
Thanks, Pablo, for referring to AutoHotkey utility.
Since I have Launchy installed which uses Alt+Space I had to modify it a but to add Shift key as shown:
; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !+{Space}ep
return
This is not really a shortcut but just a quick access to the control menu: Alt-space E P
If you can use your mouse, right click on the cmd window works as paste when I tried it.
Theoretically, the application in DOS Prompt has its own clipboard and shortcuts. To import text from Windows clipboard is "extra". However you can use Alt-Space to open system menu of Prompt window, then press E, P to select Edit, Paste menu. However, MS could provide shortcut using Win-key. There is no chance to be used in DOS application.
It took me a small while to figure out why your AutoHotkey script does not work with me:
; Use backslash instead of backtick (yes, I am a C++ programmer).
#EscapeChar \
; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return
In fact, it relies on keystrokes and consequently on keyboard layout!
So when you are, as I am, unfortunate to have only an AZERTY keyboard, your suggestion just does not work. And worse, I found no easy way to replace SendInput method or twist its environment to fix this. For example SendInput "1" just does not send digit 1.
I had to turn every character into its unicode to make it work on my computer:
#EscapeChar \
; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
clipboard3 := ""
Loop {
if (a_index>strlen(clipboard2))
break
char_asc := Asc(SubStr(clipboard2, a_Index, 1))
if (char_asc > 127 and char_asc < 256)
add_zero := "0"
else
add_zero := ""
clipboard3 := clipboard3 . "{Asc " . add_zero . char_asc . "}"
}
SendInput %clipboard3%
return
Not very simple...
If you use the clipboard manager Ditto (open source, gratis), you can simply use the shortcut to paste from Ditto, and it will paste the clipboard in CMD for you.
I followed #PabloG's steps as follows
goto http://www.autohotkey.com/ - download autohotkey
follow simple installation steps
after installation create new *.ahk file as follows right click on desktop > new > Autohotkey Script > giveAnyFileName.ahk
right click on this file > Edit
copy paste autohotkey script given by #PabloG in his answer
save and close
double click on file to run
Done now you should be able to use Ctrl+v for paste in command prompt
You could try using Texter and create something unlikely like:
./p , triggered by space and replacing the text with %c
I just tested it and it works fine. The only gotcha is to use a rare sequence, as Texter cannot restrict this to just cmd.
There are probably other utilities of this kind which could work, and even AutoHotKey, upon which Texter is built could do it better, but Texter is easy :-)
A simpler way is to use windows powershell instead of cmd. itworks fine with texter.
I've recently found that command prompt has support for context menu via the right mouse click. You can find more details here: http://www.askdavetaylor.com/copy_paste_within_microsoft_windows_command_prompt.html
Pretty simple solution may be Console 2, redefine keys and you go.
If you're a Cygwin user, you can append the following to your ~/.bashrc file:
stty lnext ^q stop undef start undef
And the following to your ~/.inputrc file:
"\C-v": paste-from-clipboard
"\C-C": copy-to-clipboard
Restart your Cygwin terminal.
(Note, I've used an uppercase C for copy, since CTRL+c is assigned to the break function on most consoles. Season to taste.)
Source
Instead of "right click"....start your session (once you're in the command prompt window) by keying Alt/SpaceBar. That will open the Command Prompt window menu and you'll see your familiar, underlined keyboard command shortcuts, just like in Windows GUI.
Good luck!
Under VISTA Command prompt:
Click on the System Icon
Select Defaults from the Menu
On the Options tab in the Options group I have
"Quick Edit Mode", "Insert Mode", and "Auto Complete" selected
I think that "Quick Edit Mode" is what makes it work.
To paste whatever is in the Clipboard at the insertion point: Right Click.
To copy from the Command Window
Select by holding down the left mouse button and dragging the pointer across what you want to copy
Once selected, right click
To paste at the insertion point, right click again.

Resources