Hey
Im lookin for a way how to save keyboard input into variable (string) so I could work further with it. can anyone help?
Keyboard input into variable
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Andrzej WegierskiRank #1,729 · 877 pointsPosted Nov 29, 2005, 11:01 PM EST
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)
Ed3 pointsPosted Nov 30, 2005, 1:12 AM EST
Gavin Roberts3 pointsPosted Nov 30, 2005, 2:50 AM EST
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