console close automatically without showing output - visual-studio-2010

i am trying to work on vs,console. when i just write:
Console.WriteLine("c#");
the console appear just for a second, without output and close automatically.
but when :
Console.ReadLine();
is added to this , it shows the output .
why is this happening with Console.WriteLine("");

Your output only appears for a second because that's all your program is doing. When you add Console.ReadLine(); or Console.ReadKey(); the console is going to wait for you to press a key before closing it.
You could also try hitting Ctrl+F5. It will add a pause with "Press any key to continue..."

Related

How to setup Toggle Key to display the shell script output during execution?

In my team they have asked me to create a shell script with toggle key option to display the command output/errors when a arrow key is pressed. And it need to hide the output when the same arrow key is pressed. Is there a way we can achieve this using a shell script?
I don't have a solution yet but the script which we are using now is throwing so many output and its making the screen loaded without so many lines of std output/errors during execution. And we would like to hide the output using the toggle key and when needed if we press a key it needs to display the output during execution.
No idea on how to start with this. Need some idea or thoughts on how to achieve this?
Expected:
Shrink the output using toggle key (say for example UP arrow key) and when needed if we press the same UP arrow key it need to display the output again.
Actual:
No code available as of now to do this function.

Can I repeat steps without repeating the steps using Cucumber?

I need to test behaviour that triggers when a user repeats a set of actions many times. I would like to end up with a scenario that looks something like this:
Scenario: Nice way
Given that I am on some screen
When I enter something into some text field
And I press the Continue button
And I go back
And I repeat the previous 2 steps 5 times
Then the application should crash
Rather than a scenario that looks like this:
Scenario: Annoying way
Given that I am on some screen
When I enter something into some text field
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
And I press the Continue button
And I go back
Then the application should crash
Is there a standard way of doing this or do I have to implement it myself?
If you have control over the step definition code try a step like this -
And I press Continue button and go back 5 times
Capture the number of times in the step definition with a variable and call existing functions in a loop for the number of times.
It can be captured by something like:
#And("^I press Continue button and go back (//d+) times")
public void iPressContinueButtonAndGoBackNTimes(int n){
//enter code here
}
To repeat arbitrary steps without having to write a new one each time, define this step
When /^I repeat "([^"]*)" (\d+) times$/ do |steps, times|
times.to_i.times do
steps.split(/;\s*/).each do |step|
step step
end
end
end
and use it like this:
When I repeat "press the Continue button; go back" 5 times
(And don't use semicolons in the names of steps that you want to repeat.)

Mapping RightAlt+Ctrl+a to send Ctrl+Delete?

I have the following map:
>!+a::SendInput,+{Delete}
It's supposed to send Ctrl+Delete (delete word after cursor) when I press RightAlt+Ctrl+a but instead it's sending a Ctrl+Alt+Delete signal so it's bringing up the Windows 7 menu of shutdown, start task manager etc.
How can I send the right signal?
Appreciate any help!
The problem you are facing is that Ctrl + Alt + Delete is hard coded and is uninterruptible. There's simply no way around it, if you press that sequence, even with the Command BlockInput enabled, Windows will re-enable input and execute the command...
Try:
>!^a:: ; + symbol is Shift ^ represents Ctrl key
KeyWait, RAlt ; Waits for Right Alt to be released before Ctrl Delete is sent
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
An alternative although it works the exact same way:
>!^a::
While (GetKeyState("RAlt", "P"))
Continue
SendInput,{Ctrl Down}{Delete}{Ctrl Up}
Return
I'll continue to pursue other options.. at the moment I can I think of no better way to do this.

vb6: interrupt endless msgbox loop

I am writing a program in VB6.
By mistake many times my code contains an endless loop, inside which there is a message box. For example:
while a>0
msgbox "a is positive"
wend
Then I press the play/run and I realize what has happened. Is there any way to stop the debugging/running of my program?
The only thing that works so far is Ctrl+Alt+Del and end task. But this way the whole visual basic closes and I lose my unsaved data. (please don't comment that I should save my program more often. I know it (now)).
Edit: I found on the internet that maybe esc or ctrl+c or ctrl+break could do the job. The first two do nothing and my laptop doesn't have a break key
Solution: I have the insert key in my laptop. on the key there is also written pause for use along with the Fn key. So I was able to break the application by pressing Ctrl+Fn+Insert (which maybe could be translated in Ctrl+Pause)
edit: link to photo of my keyboard:
ctrl + break will work. If you don't have those keys, use the on screen keyboard.
Start | Run | osk
Then press ctrl + break.

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

Resources