|
I want to send a keystroke combination to an already running app such as ms word or any other app.
|
|
|
|
|
You can use SendKeys[^] to send to the active application, but if you want to send to a specific app all the time, then see here: Sending Keystrokes to another Application in C#[^]
Be aware, this may or may not work if the target app is running at a higher level than your app!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The problem with this solution, is that the window needs to be in focus. What if I have multiple windows I want to send the keystroke to, how do I make them come into focus one by one, so I can send the keystroke one by one?
|
|
|
|
|
Did you read the links?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi All,
Below is an interview question about using recursion to add two arrays.
I can't figure it out though because it does not seem to allow any kind of index to keep track of where you are, I have been down a few roads - trying to test for null / default values in the array but because it is a byte[] type nothing worked.
Any help would be great thanks - this is not a homework question.
public AddResult UsingARecursiveAlgorithm_ValuesAreAdded(byte[] a, byte[] b)
{
var result = AddRecursive(a, b);
return new AddResult(a, b, result);
}
E.G.
Input : { 1, 1, 1 }, { 1, 1, 1 }
Result: {2,2,2}
Input : { 1, 1, 255 }, {0, 0, 1 }
Result: {1,2,0}
Conditions:
a & b are never null, and are always of the same length.
The algorithm should be non destructive to the inputs.
modified 5-Aug-15 19:12pm.
|
|
|
|
|
Well, that's a pretty stupid spec you have there. Why would anyone want to work at a place that asks that?
And is your second result correct?
|
|
|
|
|
Maybe it is unreasonable.. I thought I might be missing something.
You are right; the second result is incorrect, just noticed it.
|
|
|
|
|
Is that the code they gave you or the code you started writing?
Seriously, that's a really stupid way of adding arrays together. It's slower than just doing it in a single call because of the call overhead, limited in the size of the arrays it can handle because of limited stack space, a bit of a memory hog as you're creating new AddResult objects to hold the pile of results that get generated.
It's probably the most inefficient way you could possibly come up with to add those two arrays together.
|
|
|
|
|
Its the code they gave me.
I understand that it is inefficient but I think the question is just to test your understanding of recursive functions.
|
|
|
|
|
Well, they found out.
On top of everything else I said, there's also no way to put any kind of level parameter in there and, therefor, no way to put a bailout condition in either. The way they started the code, there's no way it'll work.
|
|
|
|
|
I have been programming for a little over a year now. I have learned the basics to a degree (through many headache induced nights) and have noticed a trend. I tend to be more enthralled with higher level concepts and avoid taking baby steps like the plague. For example, I couldn't tell you gow to programatically build a UI or make a delegate event for saving a file, but I know the MVVM pattern and how to make a lambda expression from a delegate. How bad is this trend?
|
|
|
|
|
To me this implies you have an interest in general programming concepts but aren't interested in building applications.
/ravi
|
|
|
|
|
Ironically, I make quite a few applications while learning more and more. I started off trying to make games and switched to applications because it was easier to be inspired.
|
|
|
|
|
Interesting. In my experience, most devs acquire knowledge of design patterns and more abstract concepts after several years of just writing code and building apps. It's good that you've developed an interest in MVVM early in the game.
/ravi
|
|
|
|
|
Haha yeah, the more abstract and difficult the concept is, the more likely it is for me to obsess over learning about it.
|
|
|
|
|
Speaking as someone at the other end of a career of developing and learning, you end up with a set of tools that do the LOB job and get you paid but have a VERY narrow range of capabilities.
You will also tend to miss a lot of the more elegant solutions because you simply do not understand the concepts and cannot relate them to your problem (building a really good app).
I wish I had had a formal education in computer science rather than a self taught bag of tricks. Don't get me wrong, I'm good at what I do but it a very narrow field.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm actually self taught but I have a mentor that will help me if he knows the content i'm studying (MVVM wasn't one of those, OOP concepts though, he taught me about in detail).
|
|
|
|
|
When I was learning the only support was the other side of the planet and CompuServe was the medium for communication. A mentor was the manuals, not Microsoft but Superbase, almost as bad!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
+1 for Compuserve , before that I had a huge collection of expensive and outdated books.
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
hi
i have this C# code for reading port via rs232
port = new SerialPort(MyParam._COM, Brate, Parity.None, 8, StopBits.One);
port.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(Recepcion);
private SerialPort port;
string Recibidos;
private void Recepcion(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
try
{
Recibidos = "";
Application.DoEvents();
System.Threading.Thread.Sleep(122);
Recibidos += port.ReadExisting();
this.Invoke(new EventHandler(Actualizar));
}
catch { }
string text;
decimal dTEXT;
private void Actualizar(object s, EventArgs e)
{
text = Recibidos.Trim();
lblMSG.Text = text;
}
I have a weight attached to rs232 and i get Strange reading.
for example - if the weight show 14.23 Kg
i see:
14.23 Kg
0
14.
14.2
14.23
14.23 Kg
How to show the exact weight without breaking the string ?
|
|
|
|
|
Maybe don't use port.ReadExisting() ?
Also, try using a StringBuilder rather than a string.
|
|
|
|
|
It seems you need to call port.DiscardInBuffer() after each call to ReadExisting() .
/ravi
|
|
|
|
|
thanks for the help, i'll try this and I'll update the findings.
|
|
|
|
|
Using Silverlight and c#:
I have a datagrid having PropertyGroupDescription added to it and also have Item templates in it.. If I edit a row which is exist in the middle of the grid..after saving that data by using that save button in the panel...what happened is the data grid rebinding and the pointer goes to the first record in the datagrid. I want the scroll to maintain its position to the row which is edited after its ItemSource is changed. I tried using ScrollIntoView as follows:
tblSessionDataGrid.Focus();
tblSessionDataGrid.SelectedItem = objSelectedItem;
tblSessionDataGrid.CurrentColumn = tblSessionDataGrid.Columns[0];
tblSessionDataGrid.ScrollIntoView(objSelectedItem, tblSessionDataGrid.Columns[0]);
But its now working. Can anyone please suggest where I am going wrong?
|
|
|
|
|
hi
looking for C# sample code reading weight Through rs232 - WinForm
I found some on the net - but none worked,
Even after I pointed all settings (com....BaudRate....)
thanks
|
|
|
|