How to translate KeyCode to work in Keys.SendKey

Is there a way to translate KeyCode in a way that will work if I use it in Keys.Sendkey ();

private void Manager_KeyDown(object sender, KeyEventArgs e) { Keys.SendKey(e.KeyCode.toString()); } 

I tried this way and it does not work, so there is a way to do it dynamically.

+4
source share
2 answers

Well, I don’t know which is better, but that, you have to capture all the keys in the KeyDown event and send them as String in this format from this website.

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

+2
source

Keys is an enumeration and does not contain the SendKey method. However, you can do something like this:

 SendKeys.Send(Keys.A.ToString()); 

You can also send multiple keys using string concatenation:

 SendKeys.Send(Keys.A.ToString() + Keys.B.ToString()); 

Similary, this code works for me:

 private void departmentList_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyCode; SendKeys.Send(key.ToString()); } 

Also check out this question: SendKeys :: Send, going berserk . What is your goal, if I may ask?

0
source

Source: https://habr.com/ru/post/1380774/


All Articles