1

how can I press "Enter" on c# and WPF without pressing enter on hardware keyboard ?

vahid abdi
  • 9,636
  • 4
  • 29
  • 35
kartal
  • 17,436
  • 34
  • 100
  • 145

2 Answers2

2

Ah, so you're saying SendKeys is unavailable?

Check these threads, on the MSDN forums: http://social.expression.microsoft.com/Forums/en-US/wpf/thread/915cb53a-704b-4047-8fd0-e7c5a8feae5e/

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6557c1eb-6eb5-4f4a-84d6-4ae4fb5b9dab/

Sounds like you can trap KeyDown events, but that's not exactly what you want...

Oh, wait! Check this SO thread: How can I programmatically generate keypress events in C#?

Beyond that, How and why do you need to send "Enter" without a keyboard press? There may be a different solution lurking there. :)

Community
  • 1
  • 1
Dan J
  • 16,319
  • 7
  • 50
  • 82
  • TO enable to write on autocompletebox because Focus() didn't work it just choose the control but can't enable to write untill I press enter or tab ! – kartal Aug 26 '10 at 06:42
  • Ok. So you're programmatically Focusing on the autocompletebox, and you want to send an Enter press so that (a) the user can just start typing without having to focus on the field themselves, or (b) you can programmatically "type" in the box? Are you trying to achieve (a) or (b)? – Dan J Aug 26 '10 at 16:54
0

Assuming that you're working with WindowsForms... by using SendKeys.Send("{ENTER}");

See this documentation here as well: http://msdn.microsoft.com/de-de/library/system.windows.forms.sendkeys.send.aspx

Christian
  • 4,261
  • 22
  • 24