|
abu rakan wrote: how to close all the running application like
word , notepad ,photoshop .....etc
Shut down windows. That will close all the applications - and in a very green environmentally friendly way that uses very little power.
|
|
|
|
|
thanks
but want make that witout shutdown XP
|
|
|
|
|
Over a month and you STILL can't figure this out? Nevermind searchin google, CP articles or even the message board would have given you the answer.
Ugh. I got so tired of this I gave up and coded it for you.
Here is the damn code.[^]
|
|
|
|
|
thank you
if you woudnot to replay
dont replay
i didnot ask you
|
|
|
|
|
blank[] blanklist = blank.Getblank();
foreach(blank theblank in blanklist)
{
theblank.blank();
}
If you can't figure it out, then go stupid business or some crap.
|
|
|
|
|
When you ask the same question over and over, when you have already been given the solution or told to Google an easier type of question you are going to get flamed. Now, if you want to be rude in your replies NO ONE WILL EVER HELP YOU AGAIN.
Do you understand this?
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
Windows doesn't have a utility to do this. You'll have to be a programmer and write one.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'll probably get flamed for this, but I'm responding in the hope that you'll then go away.
What you want to do shouldn't be done - it's not your computer it's the users. They get to decide when their open applications should close. (Hint to possible solution later)
You've previosly asked about stopping running processes - again, you should not do this for the above reasons, plus some may be important to the system and could potentially hang the system totally if stopped.
You've also asked about stopping Explorer. The only valid reasons to do this are if Explorer has crashed in which case your C# program will not be accessible until it's restarted, or if you're writing your own shell - which can't be done in C#.
So - don't attempt to do any of these.
The first however may be acheivable using FindWindow and DestroyWindow from user32.dll. Have a look on pinvoke.net for more info.
Now stop asking the same/rephrased question - do some coding and post back only with specific problems in your code.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
I am using C# 2008 express. When I do a textBox.Text.Length it does not count escape sequence characters in the string ex."\r\n" has length of 2 instead of 4. I am trying to have a console window show what line of a file I am sending, I use the Text.Remove command to remove the previous string that displays the last count, and append the new string that show the current count.
Ex..
textBoxConsole.Text = "Sending File....\r\n";
int len = textBoxConsole.Text.Length;
for (int i = 0; i <= 3; i++)
{
textBoxConsole.Text.Remove(len - 1);
textBoxConsole.AppendText("Line 1 of 3");
}
The above code will produce the following string:
"Sending File....\rLine 1 of 3"
The "\n" is cut off because the length was not correct. If there is more text above this more characters will be cut off because of ignored "\"s.
If anybody has a better way to do this please let me know.
Thanks!
|
|
|
|
|
Escape sequences like \r and \n are for the programmer and are converted to their proper one character representation (0x0d and 0x0a, in this case). If you want the length of the string, then assign the string to an intermediate variable first and get the length from that.
string message = "Sending File....\r\n";
int len = message.length;
textBoxConsole.Text = message;
for (int i = 0; i <= 3; i++)
{
textBoxConsole.AppendText("Line 1 of 3");
}
Hope this helps!
Jon
|
|
|
|
|
Thanks for the reply.
When I run your code the length of message is reported as 18, not 20. If I put another "\r\n" at the end of the string and it is reported as 20 not 24. Ignoring all "\"s in the string.
I need this so I know what position I am in the string so I can remove the previous string "Line 1 of 3" and replace it with the new string "Line 1 of 2". While keeping any text already in the console. I am sending thousands of lines so I can't append them into the console.
I tried to copy the textbox.Text to a string and get the length, same results.
Thanks!
|
|
|
|
|
asquaredtech wrote: When I run your code the length of message is reported as 18, not 20. If I put another "\r\n" at the end of the string and it is reported as 20 not 24. Ignoring all "\"s in the string.
It isn't ignoring the slashes. The slashes indicate the start of an escape sequence. The slashes are interpreted by the compiler as if to say this and the next character represent something other than what is displayed in the source code.
In other words, treat the "n" in "\n" as the new line character rather than as an "n".
"\t" is the representation of the tab character (singluar) becuase it is difficult to represent that in code.
"\r\n" represent the character pair carriage return and newline. Although you put four characters in the source code, there are only two character actually generated in the compiled output.
If you do actually need to represent a slash character in a string in your source code then use "\\".
asquaredtech wrote: I need this so I know what position I am in the string so I can remove the previous string "Line 1 of 3" and replace it with the new string "Line 1 of 2". While keeping any text already in the console. I am sending thousands of lines so I can't append them into the console.
One thing you could do is this. If you are displaying this on the Console , use Console.Write and finish your string with "\r" which is a carriage return. Without the newline that normally comes with it, it will return you to the start of the current line. You then overwrite the text that already exists on that line.
Many console applications use this technique when displaying progress status.
|
|
|
|
|
asquaredtech wrote: "\r\n" has length of 2 instead of 4
That count is correct. There are two characters in the string "\r\n", not four.
asquaredtech wrote: The "\n" is cut off because the length was not correct.
What (int) does the .Length method return when you measure the length of the string in the debugger?
"Sending File....\r\n".Length = 18? You expected it to be 20, right?
asquaredtech wrote: textBoxConsole.Text.Remove(len - 1);
..is this the place where your string is a character short?
I are troll
|
|
|
|
|
"T\r\n" : Len = 3, not 5
"T\r\n\r\n" : Len = 5, not 9
All "\"s are not being counted.
I subtract 1 because the .Length is 1 based, the index into the string is 0 based.
Thanks!
|
|
|
|
|
asquaredtech wrote: I subtract 1 because the .Length is 1 based, the index into the string is 0 based.
That is not correct. The length is zero based, a one based length would not make sense.
The value 4 means four characters, not three.
Also, if the length really would have been one based, you would have to add one to the value instead of subtracting one.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you for repeating what I said.
1 based = 1,2,3,4
0 based = 0,1,2,3
length of 4, 4th character has an index of 3 in the string b/c the first items index is 0.
which is why i subtract 1. if I want to remove characters after the 4th character, I send an index of 3.
|
|
|
|
|
asquaredtech wrote: Thank you for repeating what I said.
No, I didn't. What you say doesn't make sense.
asquaredtech wrote: if I want to remove characters after the 4th character, I send an index of 3.
No, you don't. If you send an index of 3 you will not remove characters after the fourth character, you will remove characters from and including the fourth character.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
1.
the lengths are correct, each character counts as 1, and of course every escaped character such as "\r" and "\n" is one character.
2.
The code you have shown and the description of the symptoms don't fit together:
String.Remove does not modify an existing string, it returns a new one; strings are immutable, you cannot change them, you can only replace them by another string. Hence your Remove statement does not achieve a single thing.
3.
If your output is line-oriented, i.e. each line is a statement and nothing needs to wrap around, then
I strongly suggest using a ListBox rather than a TextBox. It is much faster, and much easier to program
since it handles individual items without needing any concatenation (and no \r \n)
Remark: if you ever want to copy text from your XxxBox, a ListBox only supports integral-line selections,
and you then would have to do the concatenation programmatically.
|
|
|
|
|
Hi Luc
1. I understand this, I was hoping there was a way to count the "\"s.
2. The remove function allows me to remove the string "Line 1 of 3" from the text box, then append the string "Line 2 of 3" which is returned from method I call. I get the length before "Line 1 of 3" so I know where to start removing from.
3. I will try this.
Thanks for your help!
|
|
|
|
|
asquaredtech wrote: I understand this, I was hoping there was a way to count the "\"s.
Why? What purpose does it serve?
asquaredtech wrote: The remove function allows me to remove the string "Line 1 of 3" from the text box, then append the string "Line 2 of 3" which is returned from method I call. I get the length before "Line 1 of 3" so I know where to start removing from.
No, it doesn't. The string returned by the Text property is still immutable (it does not, and cannot, change). Since you don't assign the new string you've created with the Remove method back to the Text property then nothing gets updated.
|
|
|
|
|
asquaredtech wrote: I was hoping there was a way to count the "\"s.
This is non-sense, there are no backslashes in your text, they are only present in your C# source code
to tell the compiler it has to treat the next character differently, hence:
"r" is one character, and "\r" is also one character albeit a different one.
In memory at run-time they both occupy the same number of bytes, and String.Length will return 1 for each of them.
asquaredtech wrote: The remove function allows me to remove the string "Line 1 of 3"
Only if you store the return value of that method, it does NOT alter its parameters in some magical way.
|
|
|
|
|
asquaredtech wrote: textBoxConsole.Text.Remove(len - 1);
instead of this try :
textBoxConsole.Text = textBoxConsole.Text.Replace("\r\n","");
if you just wants to remove the "NewLine Char"
|
|
|
|
|
Just in case you have not yet realised that the '\'s are not really in your text.
Try to think of it like this:
If you were writing to your mum about something Fred had said to you. You would write something like
and then Fred said "How long are you staying?"
now Fred did not say open-quote blah blah ... question mark close-quote
Those are punctuation marks and are used to indicate to the reader, that the words were spoken by someone and that they were asking a question.
In C# the compiler is the reader and the '\'s are punctuation marks, except we call them 'escape characters' and in C# they indicate a non-printable character is coming. In the case of '\' the compiler says to itself
"Ah, an escape character. I must treat the next character specially because it is not printable."
It doesn't do anything with the '\'s, it throws them away. So by the time your "Sending File....\r\n" reaches the TextBox it is only 18 characters long.
In the TextBoxs' Text property it is stored in memory as a series of numbers:
S e n d i n g F i l e . . . .
83, 101, 110, 100, 105, 110, 103, 32, 70, 105, 108, 101, 46, 46, 46, 46, 13, 10
32 is the number for space character.
13 is the character for Return
10 is the character for New Line.
I hope this helps you.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Henry Minute wrote: Just in case you have not yet realised that the '\'s are not really in your text.
Try to think of it like this:
If you were writing to your mum about something Fred had said to you. You would write something like
and then Fred said "How long are you staying?"
now Fred did not say open-quote blah blah ... question mark close-quote
Those are punctuation marks and are used to indicate to the reader, that the words were spoken by someone and that they were asking a question.
That is a really good analogy. I'll have to remember that.
|
|
|
|