Hey
Im lookin for a way how to save keyboard input into variable (string) so I could work further with it. can anyone help?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gavin RobertsPosted Nov 30, 2005, 7:50 AM
private ArrayList Keys = new ArrayList();
private void InvWiz0_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
Keys.Add(e);
}
this "i think" will capture each key you press on the keyboard and add it to an arraylist. As I have added the whole KeyEventArgs object, you will be able to go through and view each one and it's properties.
You have to cast it back to an KeyEventArgs when reading tho.
ie.
object[] Keys_Ar = Keys.ToArray();
foreach(KeyEventArgs Key in Keys_Ar)
{
}
or
object[] Keys_Ar = Keys.ToArray();
for(int i = 0; i < Keys_Ar.Length; i++)
{
((KeyEventArgs)Keys_Ar[i]).property
}
P.S I hope you are not looking to use this as a keylogger.!
Gav
EdPosted Nov 30, 2005, 6:12 AM
Andrzej WegierskiPosted Nov 30, 2005, 4:01 AM
In OnKey... KeyEventArgs see Handled property.
Remember method arguments in Your own buffer to future use - string isn't good to remember all keyboard input (shift, control, alt modifiers etc)